Zelda Classic Coverage Report


Directory: src/
File: src/zc/guys.cpp
Date: 2023-10-28 10:17:38
Exec Total Coverage
Lines: 8541 12246 69.7%
Functions: 325 397 81.9%
Branches: 6741 13788 48.9%

Line Branch Exec Source
1 #include <cstring>
2 #include <stdio.h>
3 #include "base/zc_alleg.h"
4 #include "zc/guys.h"
5 #include "zc/replay.h"
6 #include "zc/zc_ffc.h"
7 #include "zc/zelda.h"
8 #include "base/zsys.h"
9 #include "base/msgstr.h"
10 #include "zc/maps.h"
11 #include "zc/hero.h"
12 #include "subscr.h"
13 #include "zc/ffscript.h"
14 #include "gamedata.h"
15 #include "defdata.h"
16 #include "zscriptversion.h"
17 #include "particles.h"
18 #include "base/zc_math.h"
19 #include "slopes.h"
20 #include "base/qrs.h"
21 #include "base/dmap.h"
22 #include "base/mapscr.h"
23 #include "base/misctypes.h"
24 #include "base/initdata.h"
25 extern particle_list particles;
26
27 extern FFScript FFCore;
28 extern ZModule zcm;
29 extern HeroClass Hero;
30 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
31
32 int32_t repaircharge=0;
33 bool adjustmagic=false;
34 bool learnslash=false;
35 int32_t wallm_load_clk=0;
36 int32_t sle_x,sle_y,sle_cnt,sle_clk=0;
37 int32_t vhead=0;
38 int32_t guycarryingitem=0;
39
40 char *guy_string[eMAXGUYS];
41
42 void never_return(int32_t index);
43 void playLevelMusic();
44
45 // If an enemy is this far out of the playing field, just remove it.
46 #define OUTOFBOUNDS ((int32_t)y>((isSideViewGravity() && canfall(id))?192:352) || y<-176 || x<-256 || x > 512)
47 //#define NEWOUTOFBOUNDS ((int32_t)y>32767 || y<-32767 || x<-32767 || x > 32767)
48 #define IGNORE_SIDEVIEW_PLATFORMS (editorflags & ENEMY_FLAG14)
49 #define OFFGRID_ENEMY (editorflags & ENEMY_FLAG15)
50
51 648969 void do_fix(zfix& coord, int32_t val, bool nearest_half = false)
52 {
53 648969 int32_t c = coord.getInt();
54
2/2
✓ Branch 0 taken 267 times.
✓ Branch 1 taken 648702 times.
648969 if(nearest_half)
55 {
56
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648702 times.
648702 if (c < 0)
57 c -= val / 2;
58 648702 else c += (val/2);
59 648702 }
60 648969 c -= c % val;
61 648969 coord = c;
62 648969 }
63
64 bool NEWOUTOFBOUNDS(zfix x, zfix y, zfix z)
65 {
66 return
67 (
68 (((int32_t)y) > FFCore.enemy_removal_point[spriteremovalY2])
69 || (((int32_t)y) < FFCore.enemy_removal_point[spriteremovalY1])
70 || (((int32_t)x) < FFCore.enemy_removal_point[spriteremovalX1])
71 || (((int32_t)x) > FFCore.enemy_removal_point[spriteremovalX2])
72 || (((int32_t)z) < FFCore.enemy_removal_point[spriteremovalZ1])
73 || (((int32_t)z) > FFCore.enemy_removal_point[spriteremovalZ2])
74 );
75 }
76
77 namespace
78 {
79 int32_t trapConstantHorizontalID;
80 int32_t trapConstantVerticalID;
81 int32_t trapLOSHorizontalID;
82 int32_t trapLOSVerticalID;
83 int32_t trapLOS4WayID;
84
85 int32_t cornerTrapID;
86 int32_t centerTrapID;
87
88 int32_t rockID;
89 int32_t zoraID;
90 int32_t statueID;
91 }
92
93 120 void identifyCFEnemies()
94 {
95 120 trapConstantHorizontalID=-1;
96 120 trapConstantVerticalID=-1;
97 120 trapLOSHorizontalID=-1;
98 120 trapLOSVerticalID=-1;
99 120 trapLOS4WayID=-1;
100 120 cornerTrapID=-1;
101 120 centerTrapID=-1;
102 120 rockID=-1;
103 120 zoraID=-1;
104 120 statueID=-1;
105
106
2/2
✓ Branch 0 taken 61440 times.
✓ Branch 1 taken 120 times.
61560 for(int32_t i=0; i<eMAXGUYS; i++)
107 {
108
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 61321 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
61440 if((guysbuf[i].flags2&cmbflag_trph) && trapLOSHorizontalID==-1)
109 119 trapLOSHorizontalID=i;
110
4/4
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 61317 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&cmbflag_trpv) && trapLOSVerticalID==-1)
111 120 trapLOSVerticalID=i;
112
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&cmbflag_trp4) && trapLOS4WayID==-1)
113 120 trapLOS4WayID=i;
114
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&cmbflag_trplr) && trapConstantHorizontalID==-1)
115 120 trapConstantHorizontalID=i;
116
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&cmbflag_trpud) && trapConstantVerticalID==-1)
117 120 trapConstantVerticalID=i;
118
119
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&eneflag_trap) && cornerTrapID==-1)
120 120 cornerTrapID=i;
121
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&eneflag_trp2) && centerTrapID==-1)
122 120 centerTrapID=i;
123
124
3/4
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 61320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&eneflag_rock) && rockID==-1)
125 120 rockID=i;
126
4/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 61315 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2&eneflag_zora) && zoraID==-1)
127 120 zoraID=i;
128
129
4/4
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 61314 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 120 times.
61440 if((guysbuf[i].flags2 & eneflag_fire) && statueID==-1)
130 120 statueID=i;
131 61440 }
132 120 }
133
134 25 int32_t random_layer_enemy()
135 {
136 25 int32_t cnt=count_layer_enemies();
137
138
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 if(cnt==0)
139 {
140 return eNONE;
141 }
142
143 25 int32_t ret=zc_oldrand()%cnt;
144 25 cnt=0;
145
146
1/2
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
25 for(int32_t i=0; i<6; ++i)
147 {
148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(tmpscr->layermap[i]!=0)
149 {
150 25 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
151
152
1/2
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
127 for(int32_t j=0; j<10; ++j)
153 {
154
2/4
✓ Branch 0 taken 127 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 127 times.
127 if(layerscreen->enemy[j]>0&&layerscreen->enemy[j]<MAXGUYS)
155 {
156
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 102 times.
127 if(cnt==ret)
157 {
158 25 return layerscreen->enemy[j];
159 }
160
161 102 ++cnt;
162 102 }
163 102 }
164 }
165 }
166
167 return eNONE;
168 25 }
169
170 39 int32_t count_layer_enemies()
171 {
172 39 int32_t cnt=0;
173
174
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 39 times.
273 for(int32_t i=0; i<6; ++i)
175 {
176
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 39 times.
234 if(tmpscr->layermap[i]!=0)
177 {
178 39 mapscr *layerscreen=&TheMaps[(tmpscr->layermap[i]-1)*MAPSCRS]+tmpscr->layerscreen[i];
179
180
2/2
✓ Branch 0 taken 390 times.
✓ Branch 1 taken 39 times.
429 for(int32_t j=0; j<10; ++j)
181 {
182
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 390 times.
390 if(layerscreen->enemy[j]!=0)
183 {
184 390 ++cnt;
185 390 }
186 390 }
187 39 }
188 234 }
189
190 39 return cnt;
191 }
192
193 145542 int32_t hero_on_wall()
194 {
195 145542 zfix lx = Hero.getX();
196 145542 zfix ly = Hero.getY();
197
198
199 //zprint2("hero_on_wall x is: %d\n", lx);
200 //zprint2("hero_on_wall y is: %d\n", ly);
201
202
4/4
✓ Branch 0 taken 135889 times.
✓ Branch 1 taken 9653 times.
✓ Branch 2 taken 4526 times.
✓ Branch 3 taken 131363 times.
145542 if(lx>=48 && lx<=192)
203 {
204
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 131211 times.
131363 if(ly==32) return up+1;
205
206
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 131051 times.
131211 if(ly==128) return down+1;
207 131051 }
208
209
4/4
✓ Branch 0 taken 134471 times.
✓ Branch 1 taken 10759 times.
✓ Branch 2 taken 11441 times.
✓ Branch 3 taken 123030 times.
145230 if(ly>=48 && ly<=112)
210 {
211
2/2
✓ Branch 0 taken 132 times.
✓ Branch 1 taken 122898 times.
123030 if(lx==32) return left+1;
212
213
2/2
✓ Branch 0 taken 122829 times.
✓ Branch 1 taken 69 times.
122898 if(lx==208) return right+1;
214 122829 }
215
216 145029 return 0;
217 145542 }
218
219 690683 bool tooclose(int32_t x,int32_t y,int32_t d)
220 {
221
2/2
✓ Branch 0 taken 511179 times.
✓ Branch 1 taken 179504 times.
690683 return (abs(int32_t(HeroX())-x)<d && abs(int32_t(HeroY())-y)<d);
222 }
223
224 2107695 bool enemy::overpit(enemy *e)
225 {
226 // This function (and shadow_overpit) has been broken since it was written, and only
227 // checked the same diagonal of the hitbox, over and over again. The bug is because both
228 // loops used the same variable name.
229 // Checking literally every pixel seems like overkill, so for now let's continue to
230 // do the single diagonal but just once. That's why the outer loop is commented out.
231
232 // for ( int32_t q = 0; q < hxsz; ++q )
233 {
234
2/2
✓ Branch 0 taken 19856068 times.
✓ Branch 1 taken 2104527 times.
21960595 for ( int32_t q = 0; q < hit_height; ++q )
235 {
236 //check every pixel of the hitbox
237
2/2
✓ Branch 0 taken 3168 times.
✓ Branch 1 taken 19852900 times.
19856068 if ( ispitfall(x+q+hxofs, y+q+hyofs) )
238 {
239 //if the hitbox is over a pit, we can't land
240 3168 return true;
241 }
242 19852900 }
243 }
244 2104527 return false;
245 2107695 }
246
247 4518811 bool enemy::shadow_overpit(enemy *e)
248 {
249 // for ( int32_t q = 0; q < hxsz; ++q )
250 {
251
2/2
✓ Branch 0 taken 66532458 times.
✓ Branch 1 taken 4514959 times.
71047417 for ( int32_t q = 0; q < hit_height; ++q )
252 {
253 //check every pixel of the hitbox
254
2/2
✓ Branch 0 taken 3852 times.
✓ Branch 1 taken 66528606 times.
66532458 if ( ispitfall(x+q+hxofs, y+q+hyofs+hit_height-2) )
255 {
256 //if the hitbox is over a pit, we can't land
257 3852 return true;
258 }
259 66528606 }
260 }
261 4514959 return false;
262 4518811 }
263
264 // Returns true iff a combo type or flag precludes enemy movement.
265 3797440 bool enemy::groundblocked(int32_t dx, int32_t dy, bool isKB)
266 {
267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3797440 times.
3797440 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
268 3797440 int32_t c = COMBOTYPE(dx,dy);
269
4/4
✓ Branch 0 taken 2492540 times.
✓ Branch 1 taken 1304900 times.
✓ Branch 2 taken 656349 times.
✓ Branch 3 taken 648551 times.
5102340 bool pit_blocks = (!(moveflags & (FLAG_CAN_PITWALK|FLAG_ONLY_PITWALK)) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
270
3/6
✓ Branch 0 taken 1291100 times.
✓ Branch 1 taken 2506340 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1291100 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3797440 bool water_blocks = (!(moveflags & (FLAG_CAN_WATERWALK|FLAG_ONLY_WATERWALK|FLAG_ONLY_SHALLOW_WATERWALK)) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB) && get_qr(qr_DROWN));
271
4/6
✓ Branch 0 taken 1326577 times.
✓ Branch 1 taken 2470863 times.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1326577 times.
✗ Branch 5 not taken.
7595483 return c==cPIT || c==cPITB || c==cPITC ||
272
4/6
✓ Branch 0 taken 1326577 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1326577 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1237082 times.
✓ Branch 5 taken 89495 times.
1326577 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
273 // Block enemies type and block enemies flags
274
2/2
✓ Branch 0 taken 1325228 times.
✓ Branch 1 taken 1235733 times.
89495 combo_class_buf[c].block_enemies&1 ||
275
3/4
✓ Branch 0 taken 1325225 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 1325225 times.
✗ Branch 3 not taken.
1325228 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
276
4/4
✓ Branch 0 taken 1324901 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 1324888 times.
✓ Branch 3 taken 13 times.
1325225 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
277 // Check for ladder-only combos which aren't dried water
278
4/4
✓ Branch 0 taken 594 times.
✓ Branch 1 taken 1324294 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 5 times.
2649771 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
279 // Check for drownable water
280
4/4
✓ Branch 0 taken 103121 times.
✓ Branch 1 taken 1221762 times.
✓ Branch 2 taken 1900 times.
✓ Branch 3 taken 101221 times.
1324883 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true, false, false)));
281 1327180 }
282
283 // Returns true iff enemy is floating and blocked by a combo type or flag.
284 4618347 bool enemy::flyerblocked(int32_t dx, int32_t dy, int32_t special, bool isKB)
285 {
286
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4618347 times.
4618347 if(moveflags & FLAG_IGNORE_BLOCKFLAGS) return false;
287
4/4
✓ Branch 0 taken 2869530 times.
✓ Branch 1 taken 1748817 times.
✓ Branch 2 taken 1521446 times.
✓ Branch 3 taken 227371 times.
6367164 bool pit_blocks = (!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !isKB));
288
3/4
✓ Branch 0 taken 2879534 times.
✓ Branch 1 taken 1738813 times.
✓ Branch 2 taken 1738813 times.
✗ Branch 3 not taken.
6357160 bool water_blocks = (!(moveflags & FLAG_CAN_WATERWALK) && (!(moveflags & FLAG_CAN_WATERDROWN) || !isKB));
289
2/2
✓ Branch 0 taken 557276 times.
✓ Branch 1 taken 4061071 times.
8679418 return ((special==spw_floater)&&
290
2/2
✓ Branch 0 taken 4054933 times.
✓ Branch 1 taken 6138 times.
4061071 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
291
1/2
✓ Branch 0 taken 4054933 times.
✗ Branch 1 not taken.
4054933 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
292
2/2
✓ Branch 0 taken 4054796 times.
✓ Branch 1 taken 137 times.
4054933 (MAPFLAG(dx,dy)==mfNOENEMY)||
293
1/2
✓ Branch 0 taken 4054796 times.
✗ Branch 1 not taken.
4054796 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
294
4/4
✓ Branch 0 taken 1240951 times.
✓ Branch 1 taken 2813845 times.
✓ Branch 2 taken 3939 times.
✓ Branch 3 taken 1237012 times.
8105653 (water_blocks && iswaterex(MAPCOMBO(dx, dy), currmap, currscr, -1, dx,dy, false, false, true)) ||
295
2/2
✓ Branch 0 taken 2807382 times.
✓ Branch 1 taken 1243475 times.
4050857 (pit_blocks && ispitfall(dx,dy))));
296 4618347 }
297 // Returns true iff a combo type or flag precludes enemy movement.
298 242814 bool groundblocked(int32_t dx, int32_t dy, guydata const& gd)
299 {
300 242814 int32_t c = COMBOTYPE(dx,dy);
301 242814 bool pit_blocks = !(gd.moveflags & FLAG_CAN_PITWALK);
302
2/2
✓ Branch 0 taken 27325 times.
✓ Branch 1 taken 215489 times.
242814 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK) && get_qr(qr_DROWN);
303
4/6
✓ Branch 0 taken 242813 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 242813 times.
✗ Branch 5 not taken.
922963 return c==cPIT || c==cPITB || c==cPITC ||
304
4/6
✓ Branch 0 taken 242813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 242813 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 218778 times.
✓ Branch 5 taken 24035 times.
242813 c==cPITD || c==cPITR || (pit_blocks && ispitfall(dx,dy)) ||
305 // Block enemies type and block enemies flags
306
2/2
✓ Branch 0 taken 242703 times.
✓ Branch 1 taken 218668 times.
24035 combo_class_buf[c].block_enemies&1 ||
307
3/4
✓ Branch 0 taken 242555 times.
✓ Branch 1 taken 148 times.
✓ Branch 2 taken 242555 times.
✗ Branch 3 not taken.
242703 MAPFLAG(dx,dy)==mfNOENEMY || MAPCOMBOFLAG(dx,dy)==mfNOENEMY ||
308
4/4
✓ Branch 0 taken 239059 times.
✓ Branch 1 taken 3496 times.
✓ Branch 2 taken 238787 times.
✓ Branch 3 taken 272 times.
242555 MAPFLAG(dx,dy)==mfNOGROUNDENEMY || MAPCOMBOFLAG(dx,dy)==mfNOGROUNDENEMY ||
309 // Check for ladder-only combos which aren't dried water
310
3/4
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 238756 times.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
477574 (combo_class_buf[c].ladder_pass&1 && !iswater_type(c)) ||
311 // Check for drownable water
312
4/4
✓ Branch 0 taken 32351 times.
✓ Branch 1 taken 206436 times.
✓ Branch 2 taken 24004 times.
✓ Branch 3 taken 8347 times.
238787 (water_blocks && !(isSideViewGravity()) && (iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)));
313 }
314
315 // Returns true iff enemy is floating and blocked by a combo type or flag.
316 115623 bool flyerblocked(int32_t dx, int32_t dy, int32_t special, guydata const& gd)
317 {
318
2/2
✓ Branch 0 taken 113300 times.
✓ Branch 1 taken 2323 times.
115623 bool pit_blocks = (!(gd.moveflags & FLAG_CAN_PITWALK) && !(gd.moveflags & FLAG_CAN_PITFALL));
319 115623 bool water_blocks = !(gd.moveflags & FLAG_CAN_WATERWALK);
320
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115623 times.
231246 return ((special==spw_floater)&&
321
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 2 times.
115623 ((COMBOTYPE(dx,dy)==cNOFLYZONE)||
322
1/2
✓ Branch 0 taken 115621 times.
✗ Branch 1 not taken.
115621 (combo_class_buf[COMBOTYPE(dx,dy)].block_enemies&4)||
323
2/2
✓ Branch 0 taken 115617 times.
✓ Branch 1 taken 4 times.
115621 (MAPFLAG(dx,dy)==mfNOENEMY)||
324
1/2
✓ Branch 0 taken 115617 times.
✗ Branch 1 not taken.
115617 (MAPCOMBOFLAG(dx,dy)==mfNOENEMY)||
325
4/4
✓ Branch 0 taken 2321 times.
✓ Branch 1 taken 113296 times.
✓ Branch 2 taken 250 times.
✓ Branch 3 taken 2071 times.
230984 (water_blocks && iswaterex(MAPCOMBO(dx,dy), currmap, currscr, -1, dx, dy, false, false, true)) ||
326
2/2
✓ Branch 0 taken 113296 times.
✓ Branch 1 taken 2071 times.
115367 (pit_blocks && ispitfall(dx,dy))));
327 }
328
329 /**********************************/
330 /******* Enemy Base Class *******/
331 /**********************************/
332
333
4/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
116230 enemy::enemy(zfix X,zfix Y,int32_t Id,int32_t Clk) : sprite()
334 58115 {
335
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 x=X;
336
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 y=Y;
337 58115 id=Id;
338 58115 clk=Clk;
339
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 floor_y=y;
340 58115 ceiling=false;
341 58115 fading = misc = clk2 = clk3 = stunclk = hclk = sclk = superman = 0;
342 58115 grumble = movestatus = posframe = timer = ox = oy = 0;
343
4/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 58115 times.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
58115 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) - ((isSideViewGravity()) ? 0 : 2);
344 58115 did_armos=true;
345 58115 script_spawned=false;
346
347 58115 d = guysbuf + (id & 0xFFF);
348 58115 hp = d->hp;
349 58115 starting_hp = hp;
350 // cs = d->cset;
351 //d variables
352
353 58115 flags=d->flags;
354 58115 flags2=d->flags2;
355 58115 s_tile=d->s_tile; //secondary (additional) tile(s)
356 58115 family=d->family;
357 58115 dcset=d->cset;
358 58115 cs=dcset;
359
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38815 times.
✓ Branch 3 taken 19300 times.
58115 anim=get_qr(qr_NEWENEMYTILES)?d->e_anim:d->anim;
360 58115 dp=d->dp;
361 58115 wdp=d->wdp;
362 58115 wpn=d->weapon;
363 58115 wpnsprite = d-> wpnsprite; //2.6 -Z
364 58115 rate=d->rate;
365 58115 hrate=d->hrate;
366
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dstep=d->step;
367 58115 homing=d->homing;
368 58115 dmisc1=d->misc1;
369 58115 dmisc2=d->misc2;
370 58115 dmisc3=d->misc3;
371 58115 dmisc4=d->misc4;
372 58115 dmisc5=d->misc5;
373 58115 dmisc6=d->misc6;
374 58115 dmisc7=d->misc7;
375 58115 dmisc8=d->misc8;
376 58115 dmisc9=d->misc9;
377 58115 dmisc10=d->misc10;
378 58115 dmisc11=d->misc11;
379 58115 dmisc12=d->misc12;
380 58115 dmisc13=d->misc13;
381 58115 dmisc14=d->misc14;
382 58115 dmisc15=d->misc15;
383 58115 dmisc16=d->misc16;
384 58115 dmisc17=d->misc17;
385 58115 dmisc18=d->misc18;
386 58115 dmisc19=d->misc19;
387 58115 dmisc20=d->misc20;
388 58115 dmisc21=d->misc21;
389 58115 dmisc22=d->misc22;
390 58115 dmisc23=d->misc23;
391 58115 dmisc24=d->misc24;
392 58115 dmisc25=d->misc25;
393 58115 dmisc26=d->misc26;
394 58115 dmisc27=d->misc27;
395 58115 dmisc28=d->misc28;
396 58115 dmisc29=d->misc29;
397 58115 dmisc30=d->misc30;
398 58115 dmisc31=d->misc31;
399 58115 dmisc32=d->misc32;
400
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 436 times.
✓ Branch 3 taken 57679 times.
58115 if (get_qr(qr_BROKEN_ATTRIBUTE_31_32))
401 {
402 57679 dmisc31 = dmisc32;
403 57679 dmisc32 = 0;
404 57679 }
405 58115 spr_shadow=d->spr_shadow;
406 58115 spr_death=d->spr_death;
407 58115 spr_spawn=d->spr_spawn;
408
409
2/2
✓ Branch 0 taken 2382715 times.
✓ Branch 1 taken 58115 times.
2440830 for(int32_t i=0; i<edefLAST255; i++)
410 2382715 defense[i]=d->defense[i];
411
412 58115 bgsfx=d->bgsfx;
413 58115 hitsfx=d->hitsfx;
414 58115 deadsfx=d->deadsfx;
415 58115 bosspal=d->bosspal;
416 58115 parent_script_UID = 0;
417
418 58115 frozentile = d->frozentile;
419
420 58115 frozencset = d->frozencset;
421 58115 frozenclock = 0;
422
2/2
✓ Branch 0 taken 581150 times.
✓ Branch 1 taken 58115 times.
639265 for ( int32_t q = 0; q < 10; q++ ) frozenmisc[q] = d->frozenmisc[q];
423
424
2/2
✓ Branch 0 taken 58115 times.
✓ Branch 1 taken 987955 times.
1046070 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) hitby[q] = 0;
425 //firesfx = 0; //t.b.a -Z
426 58115 isCore = true; //t.b.a
427 58115 parentCore = 0; //t.b.a
428
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script_UID = FFCore.GetScriptObjectUID(UID_TYPE_NPC); //This is used by child npcs.
429
430 58115 firesfx = d->firesfx;
431
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) movement[q] = d->movement[q];
432
2/2
✓ Branch 0 taken 1859680 times.
✓ Branch 1 taken 58115 times.
1917795 for ( int32_t q = 0; q < 32; q++ ) new_weapon[q] = d->new_weapon[q];
433
434
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 script = (d->script >= 0) ? d->script : 0; //Dont assign invalid data.
435 58115 waitdraw = 0;
436
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 weaponscript = (d->weaponscript >= 0) ? d->weaponscript : 0; //Dont assign invalid data.
437
438
2/2
✓ Branch 0 taken 464920 times.
✓ Branch 1 taken 58115 times.
523035 for ( int32_t q = 0; q < 8; q++ )
439 {
440 464920 initD[q] = d->initD[q];
441 //Z_scripterrlog("(enemy::enemy(zfix)): Loading weapon InitD[%d] to an enemy with a value of (%d)\n",q,d->weap_initiald[q]);
442 464920 weap_initiald[q] = d->weap_initiald[q];
443 //al_trace("Guys.cpp: Assigning guy.initD[%d]: %d\n",q, d->initD.initD[q]);
444 //al_trace("Guys.cpp: Assigning guy.initD[%d] from d->initD[%d]: %d\n",q,q, d->initD[q]);
445 //al_trace("Guys.cpp: guy.initD[%d] is: %d\n",q, initD[q]);
446 464920 }
447
2/2
✓ Branch 0 taken 116230 times.
✓ Branch 1 taken 58115 times.
174345 for ( int32_t q = 0; q < 2; q++ )
448 {
449 116230 initA[q] = d->initA[q];
450 116230 weap_initiala[q] = d->weap_initiala[q];
451 116230 }
452
453 58115 stickclk = 0;
454 58115 submerged = false;
455 58115 didScriptThisFrame = false;
456 58115 ffcactivated = 0;
457 58115 hitdir = -1;
458 58115 dialogue_str = 0; //set by spawn flags.
459 58115 editorflags = d->editorflags; //set by Enemy Editor
460 //Set the drawing flag for this sprite.
461
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (editorflags&ENEMY_FLAG12) ) { drawflags |= sprdrawflagALWAYSOLDDRAWS; }
462
463
464
2/2
✓ Branch 0 taken 8231 times.
✓ Branch 1 taken 49884 times.
58115 if(bosspal>-1)
465 {
466
1/2
✓ Branch 0 taken 8231 times.
✗ Branch 1 not taken.
8231 loadpalset(csBOSS,pSprite(bosspal));
467 8231 }
468
469
2/2
✓ Branch 0 taken 26009 times.
✓ Branch 1 taken 32106 times.
58115 if(bgsfx>-1)
470 {
471
1/2
✓ Branch 0 taken 26009 times.
✗ Branch 1 not taken.
26009 cont_sfx(bgsfx);
472 26009 }
473
474
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38815 times.
✓ Branch 3 taken 19300 times.
58115 if(get_qr(qr_NEWENEMYTILES))
475 {
476 38815 o_tile=d->e_tile;
477 38815 frate = d->e_frate;
478 38815 }
479 else
480 {
481 19300 o_tile=d->tile;
482 19300 frate = d->frate;
483 }
484
485 58115 tile=0; //init to 0 here, but set it later.
486
487 58115 scripttile = -1;
488 58115 scriptflip = -1;
489 58115 do_animation = 1;
490 58115 immortal = false;
491 58115 noSlide = false;
492 58115 deathexstate = -1;
493
494 58115 hashero=false;
495
496 // If they forgot the invisibility flag, here's another failsafe:
497
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 55257 times.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 2764 times.
58115 if(o_tile==0 && family!=eeSPINTILE)
498 2764 flags |= guy_invisible;
499
500 // step = d->step/100.0;
501 // To preserve the odd step values for Keese & Gleeok heads. -L
502
5/8
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6746 times.
✓ Branch 5 taken 51369 times.
✓ Branch 6 taken 6746 times.
✗ Branch 7 not taken.
58115 if(dstep==62.0) dstep+=0.5;
503
5/8
✓ Branch 0 taken 51369 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51369 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 360 times.
✓ Branch 5 taken 51009 times.
✓ Branch 6 taken 360 times.
✗ Branch 7 not taken.
51369 else if(dstep==89) dstep-=1/9;
504
505
5/10
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58115 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 58115 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 58115 times.
✗ Branch 9 not taken.
58115 step = zslongToFix(dstep*100);
506
507
508 58115 item_set = d->item_set;
509 58115 grumble = d->grumble;
510
511
2/2
✓ Branch 0 taken 45387 times.
✓ Branch 1 taken 12728 times.
58115 if(frate == 0)
512 12728 frate = 256;
513
514 58115 leader = itemguy = dying = scored = false;
515 58115 canfreeze = count_enemy = true;
516 58115 mainguy = !(flags & guy_doesntcount);
517
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 dir = zc_oldrand()&3;
518
519 //2.6 Enemy Editor Hit and TIle Sizes
520
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
521 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
522 // al_trace("Enemy txsz:%i\n", txsz);
523
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
525
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
526
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
527
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
528
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
529 // if ( (d->SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = d->hzofs;
530
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
532 {
533 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
534 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
535 }
536
537
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 58115 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
58115 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
538
539 58115 SIZEflags = d->SIZEflags;
540
541
8/10
✓ Branch 0 taken 58027 times.
✓ Branch 1 taken 88 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 58027 times.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 87 times.
58115 if((wpn==ewBomb || wpn==ewSBomb) && family!=eeOTHER && family!=eeFIRE && (family!=eeWALK || dmisc2 != e2tBOMBCHU))
542 1 wpn = 0;
543
544 //tile should never be 0 after init --Z (failsafe)
545
4/6
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 57108 times.
✓ Branch 5 taken 1007 times.
58115 if (tile <= 0 && FFCore.getQuestHeaderInfo(vZelda) >= 0x255) {tile = o_tile;}
546
547 //Moveflags; for gravity and pit interaction
548 58115 moveflags = d->moveflags;
549
3/4
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50647 times.
✓ Branch 3 taken 7468 times.
58115 if(!can_pitfall(false))
550 {
551 //Some enemies must not interact with pits. Force their flags, for sanity's sake.
552 7468 moveflags &= ~FLAG_CAN_PITFALL;
553 7468 moveflags &= ~FLAG_CAN_WATERDROWN;
554 7468 }
555
556
1/2
✓ Branch 0 taken 58115 times.
✗ Branch 1 not taken.
58115 shieldCanBlock = get_qr(qr_GOHMA_UNDAMAGED_BUG)?true:false;
557 58115 }
558
559 598 int32_t enemy::getScriptUID() { return script_UID; }
560 void enemy::setScriptUID(int32_t new_id) { script_UID = new_id; }
561 57970 enemy::~enemy()
562 57970 {
563
2/4
✓ Branch 0 taken 57970 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57970 times.
✗ Branch 3 not taken.
57970 FFCore.deallocateAllScriptOwned(ScriptType::NPC, getUID());
564
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 57966 times.
57970 if(hashero)
565 {
566
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 Hero.setEaten(0);
567 4 hashero=false;
568 4 }
569 57970 }
570
571
572 bool enemy::is_move_paused()
573 {
574 return (clk<0 || dying || stunclk || watch || ceiling || frozenclock || fallclk || drownclk);
575 }
576
577 bool enemy::scr_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
578 {
579 int32_t yg = (special==spw_floater)?8:0;
580 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
581 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
582 if(input_x == -1000)
583 input_x = dx;
584 if(input_y == -1000)
585 input_y = dy;
586
587 if(!(moveflags & FLAG_IGNORE_SCREENEDGE)
588 && ((input_x<(16-nb)) || (input_y<zc_max(16-yg-nb,0))
589 || ((input_x+hit_width-1) >= (240+nb)) || ((input_y+hit_height-1) >= (160+nb))))
590 return true;
591
592 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
593 {
594 if(ispitfall(dx,dy))
595 return true;
596 }
597
598 bool flying = false;
599 bool cansolid = false;
600 if(moveflags & FLAG_IGNORE_SOLIDITY)
601 cansolid = true;
602 switch(special)
603 {
604 case spw_clipbottomright:
605 if(dy>=128 || dx>=208) return true;
606 break;
607 case spw_clipright:
608 break; //if(input_x>=208) return true; break;
609
610 case spw_wizzrobe: // fall through
611 case spw_floater: // Special case for fliers and wizzrobes - hack!
612 {
613 if(isdungeon() && !(moveflags & FLAG_IGNORE_SCREENEDGE))
614 {
615 if(dy < 32-yg || dy >= 144) return true;
616 if(dx < 32 || dx >= 224) return true;
617 }
618 if(!(moveflags & FLAG_IGNORE_BLOCKFLAGS) && flyerblocked(dx, dy, special, kb))
619 return true;
620 cansolid = true;
621 flying = true;
622 }
623 }
624
625 dx &= ~7;
626 dy &= ~7;
627
628 if(!flying && !(moveflags & FLAG_IGNORE_BLOCKFLAGS) && groundblocked(dx,dy,kb)) return true;
629
630 if (dx < 0 || dx > 255 || dy < 0 || dy > 175)
631 return !(moveflags & FLAG_IGNORE_SCREENEDGE);
632 //_walkflag code
633 mapscr *s1, *s2;
634 s1=(((*tmpscr).layermap[0]-1)>=0)?tmpscr2:NULL;
635 s2=(((*tmpscr).layermap[1]-1)>=0)?tmpscr2+1:NULL;
636
637 int32_t cpos=(dx>>4)+(dy&0xF0);
638 int32_t ci = tmpscr->data[cpos], ci1 = (s1?s1:tmpscr)->data[cpos], ci2 = (s2?s2:tmpscr)->data[cpos];
639 newcombo const& c = combobuf[ci];
640 newcombo const& c1 = combobuf[ci1];
641 newcombo const& c2 = combobuf[ci2];
642
643 int32_t b=1;
644 if(dx&8) b<<=2;
645 if(dy&8) b<<=1;
646
647 #define iwtr(cmb, x, y, shallow) \
648 (shallow \
649 ? iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, true, false) \
650 && !iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false) \
651 : iswaterex(cmb, currmap, currscr, -1, dx, dy, false, false, false, false, false))
652 bool wtr = iwtr(ci, dx, dy, false);
653 bool shwtr = iwtr(ci, dx, dy, true);
654 bool pit = ispitfall(dx,dy);
655
656 bool canwtr = (moveflags & FLAG_CAN_WATERWALK) || ((moveflags & FLAG_CAN_WATERDROWN) && kb);
657 bool canpit = (moveflags & FLAG_CAN_PITWALK) || ((moveflags & FLAG_CAN_PITFALL) && kb);
658 bool needwtr = (moveflags & FLAG_ONLY_WATERWALK);
659 bool needshwtr = (moveflags & FLAG_ONLY_SHALLOW_WATERWALK);
660 bool needpit = (moveflags & FLAG_ONLY_PITWALK);
661
662 if(!cansolid)
663 {
664 int32_t cwalkflag = c.walk & 0xF;
665 if (c.type == cBRIDGE && get_qr(qr_OLD_BRIDGE_COMBOS)) cwalkflag = 0;
666 if (s1)
667 {
668 if (c1.type == cBRIDGE)
669 {
670 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
671 {
672 int efflag = (c1.walk & 0xF0)>>4;
673 int newsolid = (c1.walk & 0xF);
674 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
675 }
676 else cwalkflag &= c1.walk;
677 }
678 else cwalkflag |= c1.walk & 0xF;
679 }
680 if (s2)
681 {
682 if (c2.type == cBRIDGE)
683 {
684 if (!get_qr(qr_OLD_BRIDGE_COMBOS))
685 {
686 int efflag = (c2.walk & 0xF0)>>4;
687 int newsolid = (c2.walk & 0xF);
688 cwalkflag = ((newsolid | cwalkflag) & (~efflag)) | (newsolid & efflag);
689 }
690 else cwalkflag &= c2.walk;
691 }
692 else cwalkflag |= c2.walk & 0xF;
693 }
694 if(cwalkflag & b)
695 return true;
696 }
697 if(needwtr || needshwtr || needpit)
698 {
699 bool ret = true;
700 if (needwtr && wtr) ret = false;
701 else if (needshwtr && shwtr) ret = false;
702 else if (needpit && pit) ret = false;
703 return ret;
704 }
705 else if(wtr && !canwtr)
706 return true;
707 else if(pit && !canpit)
708 return true;
709
710 return false;
711 }
712
713 bool enemy::scr_canmove(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv)
714 {
715 if(!(dx || dy)) return true;
716 zfix bx = x+hxofs, by = y+hyofs; //left/top
717 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
718 if(!ign_sv && dy < 0) //check gravity
719 {
720 if((moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
721 return false;
722 }
723
724 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
725
726 if(dx && !dy)
727 {
728 if(dx < 0)
729 {
730 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
731 int mx = (bx+dx).getFloor();
732 for(zfix ty = 0; by+ty < ry; ty += 8)
733 {
734 if(scr_walkflag(mx, by+ty, special, left, mx, by, kb))
735 return false;
736 }
737 if(scr_walkflag(mx, ry, special, left, mx, by, kb))
738 return false;
739 if(nosolid && collide_object(bx+dx,by,-dx,hit_height,this))
740 return false;
741 }
742 else
743 {
744 int mx = (rx+dx).getCeil();
745 int lx = mx-hit_width+1;
746 for(zfix ty = 0; by+ty < ry; ty += 8)
747 {
748 if(scr_walkflag(mx, by+ty, special, right, lx, by, kb))
749 return false;
750 }
751 if(scr_walkflag(mx, ry, special, right, lx, by, kb))
752 return false;
753 if(nosolid && collide_object(bx+hit_width,by,dx,hit_height,this))
754 return false;
755 }
756 }
757 else if(dy && !dx)
758 {
759 if(dy < 0)
760 {
761 special = (special==spw_clipbottomright)?spw_none:special;
762 int my = (by+dy).getFloor();
763 for(zfix tx = 0; bx+tx < rx; tx += 8)
764 {
765 if(scr_walkflag(bx+tx, my, special, up, bx, my, kb))
766 return false;
767 }
768 if(scr_walkflag(rx, my, special, up, bx, my, kb))
769 return false;
770 if(nosolid && collide_object(bx,by+dy,hit_width,-dy,this))
771 return false;
772 }
773 else
774 {
775 int my = (ry+dy).getCeil();
776 int ly = my-hit_height+1;
777 for(zfix tx = 0; bx+tx < rx; tx += 8)
778 {
779 if(scr_walkflag(bx+tx, my, special, down, bx, ly, kb))
780 return false;
781 }
782 if(scr_walkflag(rx, my, special, down, bx, ly, kb))
783 return false;
784 if(nosolid && collide_object(bx,by+hit_height,hit_width,dy,this))
785 return false;
786 }
787 }
788 else //! Untested, and currently unused.
789 {
790 return scr_canmove(dx, 0, special, kb, ign_sv) && scr_canmove(dy, 0, special, kb, ign_sv);
791 }
792 return true;
793 }
794
795 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb)
796 {
797 zfix bx = dx+hxofs, by = dy+hyofs; //left/top
798 zfix rx = bx+hit_width-1, ry = by+hit_height-1; //right/bottom
799
800 bool nosolid = !((moveflags & FLAG_IGNORE_SOLIDITY) || (special==spw_wizzrobe) || (special==spw_floater));
801
802 if(nosolid && collide_object(bx,by,hit_width,hit_height,this))
803 return false;
804 for(zfix ty = 0; by+ty < ry; ty += 8)
805 {
806 for(zfix tx = 0; bx+tx < rx; tx += 8)
807 {
808 if(scr_walkflag(bx+tx, by+ty, special, -1, -1000, -1000, kb))
809 return false;
810 }
811 if(scr_walkflag(rx, by+ty, special, -1, -1000, -1000, kb))
812 return false;
813 }
814 for(zfix tx = 0; bx+tx < rx; tx += 8)
815 {
816 if(scr_walkflag(bx+tx, ry, special, -1, -1000, -1000, kb))
817 return false;
818 }
819 if(scr_walkflag(rx, ry, special, -1, -1000, -1000, kb))
820 return false;
821 return true;
822 }
823
824 bool enemy::scr_canplace(zfix dx, zfix dy, int32_t special, bool kb, int32_t nwid, int32_t nhei)
825 {
826 auto oxsz = hit_width, oysz = hit_height;
827 if(nwid > -1) hit_width = nwid;
828 if(nhei > -1) hit_height = nhei;
829 bool ret = scr_canplace(dx,dy,special,kb);
830 hit_width = oxsz; hit_height = oysz;
831 return ret;
832 }
833
834 bool enemy::movexy(zfix dx, zfix dy, int32_t special, bool kb, bool ign_sv, bool earlyret)
835 {
836 bool ret = true;
837 if(!ign_sv && dy < 0 && (moveflags & FLAG_OBEYS_GRAV) && isSideViewGravity())
838 dy = 0;
839 const int scl = 2;
840 while(abs(dx) > scl || abs(dy) > scl)
841 {
842 if(abs(dx) > abs(dy))
843 {
844 int32_t tdx = dx.sign() * scl;
845 if(movexy(tdx, 0, special, kb, ign_sv, earlyret))
846 dx -= tdx;
847 else
848 {
849 if(earlyret) return false;
850 dx = tdx;
851 ret = false;
852 }
853 }
854 else
855 {
856 int32_t tdy = dy.sign() * scl;
857 if(movexy(0, tdy, special, kb, ign_sv, earlyret))
858 dy -= tdy;
859 else
860 {
861 if(earlyret) return false;
862 dy = tdy;
863 ret = false;
864 }
865 }
866 }
867
868 if(dx)
869 {
870 if(scr_canmove(dx, 0, special, kb, ign_sv))
871 x += dx;
872 else
873 {
874 if(earlyret) return false;
875 ret = false;
876 int xsign = dx.sign();
877 while(scr_canmove(xsign, 0, special, kb, ign_sv))
878 {
879 x += xsign;
880 dx -= xsign;
881 }
882 if(dx)
883 {
884 dx.doDecBound(0,-9999, 0,9999);
885 dx = binary_search_zfix(dx.decsign(), dx, [&](zfix val, zfix& retval){
886 if(scr_canmove(val, 0, special, kb, ign_sv))
887 {
888 retval = val;
889 return BSEARCH_CONTINUE_AWAY0;
890 }
891 else return BSEARCH_CONTINUE_TOWARD0;
892 });
893 x += dx;
894 }
895 }
896 }
897 if(dy)
898 {
899 if(scr_canmove(0, dy, special, kb, ign_sv))
900 y += dy;
901 else
902 {
903 if(earlyret) return false;
904 ret = false;
905 int ysign = dy.sign();
906 while(scr_canmove(0, ysign, special, kb, ign_sv))
907 {
908 y += ysign;
909 dy -= ysign;
910 }
911 if(dy)
912 {
913 dy.doDecBound(0,-9999, 0,9999);
914 dy = binary_search_zfix(dy.decsign(), dy, [&](zfix val, zfix& retval){
915 if(scr_canmove(0, val, special, kb, ign_sv))
916 {
917 retval = val;
918 return BSEARCH_CONTINUE_AWAY0;
919 }
920 else return BSEARCH_CONTINUE_TOWARD0;
921 });
922 y += dy;
923 }
924 }
925 }
926 return ret;
927 }
928
929 bool enemy::moveDir(int32_t dir, zfix px, int32_t special, bool kb, bool earlyret)
930 {
931 static const zfix diagrate = zslongToFix(7071);
932 switch(NORMAL_DIR(dir))
933 {
934 case up:
935 return movexy(0, -px, special, kb, false, earlyret);
936 case down:
937 return movexy(0, px, special, kb, false, earlyret);
938 case left:
939 return movexy(-px, 0, special, kb, false, earlyret);
940 case right:
941 return movexy(px, 0, special, kb, false, earlyret);
942 case r_up:
943 return movexy(px*diagrate, -px*diagrate, special, kb, false, earlyret);
944 case r_down:
945 return movexy(px*diagrate, px*diagrate, special, kb, false, earlyret);
946 case l_up:
947 return movexy(-px*diagrate, -px*diagrate, special, kb, false, earlyret);
948 case l_down:
949 return movexy(-px*diagrate, px*diagrate, special, kb, false, earlyret);
950 }
951 return false;
952 }
953
954 bool enemy::moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb, bool earlyret)
955 {
956 double v = degrees.getFloat() * PI / 180.0;
957 zfix dx = zc::math::Cos(v)*px, dy = zc::math::Sin(v)*px;
958 return movexy(dx, dy, special, kb, false, earlyret);
959 }
960
961 bool enemy::can_movexy(zfix dx, zfix dy, int32_t special, bool kb)
962 {
963 zfix tx = x, ty = y;
964 bool ret = movexy(dx, dy, special, kb, false, true);
965 x = tx;
966 y = ty;
967 return ret;
968 }
969 bool enemy::can_moveDir(int32_t dir, zfix px, int32_t special, bool kb)
970 {
971 zfix tx = x, ty = y;
972 bool ret = moveDir(dir, px, special, kb, true);
973 x = tx;
974 y = ty;
975 return ret;
976 }
977 bool enemy::can_moveAtAngle(zfix degrees, zfix px, int32_t special, bool kb)
978 {
979 zfix tx = x, ty = y;
980 bool ret = moveAtAngle(degrees, px, special, kb, true);
981 x = tx;
982 y = ty;
983 return ret;
984 }
985
986 // Handle pitfalls
987 21148762 bool enemy::do_falling(int32_t index)
988 {
989
2/2
✓ Branch 0 taken 21148620 times.
✓ Branch 1 taken 142 times.
21148762 if(fallclk > 0)
990 {
991
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
142 if(fallclk == PITFALL_FALL_FRAMES && fallCombo) sfx(combobuf[fallCombo].attribytes[0], pan(x.getInt()));
992
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 4 times.
142 if(!--fallclk)
993 {
994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(immortal) //Keep alive forever
995 ++fallclk; //force another frame of falling.... forever.
996
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 else if(dying) //Give 1 frame for script revival
997 {
998
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags&guy_neverret)
999 never_return(index);
1000
1001
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(leader)
1002 kill_em_all();
1003
1004 //leave_item(); //Don't drop items in pits!
1005 2 stop_bgsfx(index);
1006 2 return true;
1007 }
1008 else
1009 {
1010 2 try_death(true); //Force death
1011 2 ++fallclk; //force another frame of falling
1012 }
1013 2 }
1014
1015 140 wpndata& spr = wpnsbuf[QMisc.sprites[sprFALL]];
1016 140 cs = spr.csets & 0xF;
1017
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t fr = spr.frames ? spr.frames : 1;
1018
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 int32_t spd = spr.speed ? spr.speed : 1;
1019 140 int32_t animclk = (PITFALL_FALL_FRAMES-fallclk);
1020
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
140 tile = spr.tile + zc_min(animclk / spd, fr-1);
1021 140 }
1022 21148760 return false;
1023 21148762 }
1024
1025 // Handle drowning in water
1026 21148620 bool enemy::do_drowning(int32_t index)
1027 {
1028
1/2
✓ Branch 0 taken 21148620 times.
✗ Branch 1 not taken.
21148620 if(drownclk > 0)
1029 {
1030 //if(drownclk == WATER_DROWN_FRAMES && drownCombo) sfx(combobuf[drownCombo].attribytes[0], pan(x.getInt()));
1031 //!TODO: Drown SFX
1032 if(!--drownclk)
1033 {
1034 if(immortal) //Keep alive forever
1035 ++drownclk; //force another frame of falling.... forever.
1036 else if(dying) //Give 1 frame for script revival
1037 {
1038 if(flags&guy_neverret)
1039 never_return(index);
1040
1041 if(leader)
1042 kill_em_all();
1043
1044 //leave_item(); //Don't drop items in pits!
1045 stop_bgsfx(index);
1046 return true;
1047 }
1048 else
1049 {
1050 try_death(true); //Force death
1051 ++drownclk; //force another frame of falling
1052 }
1053 }
1054
1055 if (drownCombo && combobuf[drownCombo].usrflags&cflag1)
1056 {
1057 wpndata &spr = wpnsbuf[QMisc.sprites[sprLAVADROWN]];
1058 cs = spr.csets & 0xF;
1059 int32_t fr = spr.frames ? spr.frames : 1;
1060 int32_t spd = spr.speed ? spr.speed : 1;
1061 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1062 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1063 }
1064 else
1065 {
1066 wpndata &spr = wpnsbuf[QMisc.sprites[sprDROWN]];
1067 cs = spr.csets & 0xF;
1068 int32_t fr = spr.frames ? spr.frames : 1;
1069 int32_t spd = spr.speed ? spr.speed : 1;
1070 int32_t animclk = (WATER_DROWN_FRAMES-drownclk);
1071 tile = spr.tile + zc_min((animclk % (spd*fr))/spd, fr-1);
1072 }
1073 }
1074 21148620 return false;
1075 21148620 }
1076
1077 // Supplemental animation code that all derived classes should call
1078 // as a return value for animate().
1079 // Handles the death animation and returns true when enemy is finished.
1080 21532885 bool enemy::Dead(int32_t index)
1081 {
1082
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21531056 times.
21532885 if(immortal)
1083 {
1084 1829 dying = false;
1085 1829 return false;
1086 }
1087
2/2
✓ Branch 0 taken 449834 times.
✓ Branch 1 taken 21081222 times.
21531056 if(dying)
1088 {
1089
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 449833 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
449834 if(deathexstate > -1 && deathexstate < 32)
1090 {
1091 1 setxmapflag(1<<deathexstate);
1092 1 deathexstate = -1;
1093 1 }
1094 449834 --clk2;
1095
1096
4/4
✓ Branch 0 taken 445139 times.
✓ Branch 1 taken 4695 times.
✓ Branch 2 taken 21421 times.
✓ Branch 3 taken 2961 times.
449834 if((get_qr(qr_HARDCODED_ENEMY_ANIMS) && clk2==12)
1097
2/2
✓ Branch 0 taken 24382 times.
✓ Branch 1 taken 420757 times.
445139 && hp>-1000) // not killed by ringleader
1098 21421 death_sfx();
1099
1100
2/2
✓ Branch 0 taken 425254 times.
✓ Branch 1 taken 24580 times.
449834 if(clk2==0)
1101 {
1102
2/2
✓ Branch 0 taken 24174 times.
✓ Branch 1 taken 406 times.
24580 if(flags&guy_neverret)
1103 406 never_return(index);
1104
1105
2/2
✓ Branch 0 taken 24523 times.
✓ Branch 1 taken 57 times.
24580 if(leader)
1106 57 kill_em_all();
1107
1108 24580 leave_item();
1109 24580 }
1110
1111 449834 stop_bgsfx(index);
1112 449834 return (clk2==0);
1113 }
1114
1115 21081222 return false;
1116 21532885 }
1117
1118 // Basic animation code that all derived classes should call.
1119 // The one with an index is the one that is called by
1120 // the guys sprite list; index is the enemy's index in the list.
1121 21148762 bool enemy::animate(int32_t index)
1122 {
1123
2/2
✓ Branch 0 taken 896465 times.
✓ Branch 1 taken 20252297 times.
21148762 if(sclk <= 0) hitdir = -1;
1124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148762 times.
21148762 if(switch_hooked)
1125 {
1126 if(get_qr(qr_SWITCHOBJ_RUN_SCRIPT))
1127 {
1128 //Run its script
1129 if (!didScriptThisFrame)
1130 {
1131 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1132 {
1133 return 0; //Avoid NULLPO if this object deleted itself
1134 }
1135 }
1136 }
1137 return false;
1138 }
1139
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 21148760 times.
21148762 if(do_falling(index)) return true;
1140
2/2
✓ Branch 0 taken 140 times.
✓ Branch 1 taken 21148620 times.
21148760 else if(fallclk)
1141 {
1142 //clks
1143
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 60 times.
140 if(hclk>0)
1144 60 --hclk;
1145
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(stunclk>0)
1146 --stunclk;
1147
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( frozenclock > 0 )
1148 --frozenclock;
1149
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if(hashero)
1150 {
1151 Hero.setX(x);
1152 Hero.setY(y);
1153 Hero.fallCombo = fallCombo;
1154 Hero.fallclk = fallclk;
1155 hashero = false; //Let Hero go if falling
1156 }
1157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!didScriptThisFrame)
1158 {
1159 140 run_script(MODE_NORMAL);
1160 140 }
1161 140 return false;
1162 }
1163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if(do_drowning(index)) return true;
1164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 else if(drownclk)
1165 {
1166 //clks
1167 if(hclk>0)
1168 --hclk;
1169 if(stunclk>0)
1170 --stunclk;
1171 if ( frozenclock > 0 )
1172 --frozenclock;
1173 if(hashero)
1174 {
1175 Hero.setX(x);
1176 Hero.setY(y);
1177 Hero.drownclk = drownclk;
1178 hashero = false; //Let Hero go if falling
1179 }
1180 if (!didScriptThisFrame)
1181 {
1182 run_script(MODE_NORMAL);
1183 }
1184 return false;
1185 }
1186 21148620 int32_t nx = real_x(x);
1187 21148620 int32_t ny = real_y(y);
1188
1189
4/4
✓ Branch 0 taken 15590435 times.
✓ Branch 1 taken 5558185 times.
✓ Branch 2 taken 3126427 times.
✓ Branch 3 taken 12464008 times.
21148620 if(ox!=nx || oy!=ny)
1190 {
1191 8684612 posframe=(posframe+1)%(get_qr(qr_NEWENEMYTILES)?4:2);
1192 8684612 }
1193
1194 21148620 ox = nx;
1195 21148620 oy = ny;
1196
1197 // Maybe they fell off the bottom in sideview, or were moved by a script.
1198
1199 //Check offscreen settings. I wrote it this way for clarity and to simplify testing. -Z
1200
2/2
✓ Branch 0 taken 1829 times.
✓ Branch 1 taken 21146791 times.
21148620 if ( immortal )
1201 {
1202 //skip, as it can go out of bounds, from immortality
1203 1829 }
1204
2/6
✓ Branch 0 taken 21146791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21146791 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
21146791 else if ( (moveflags & FLAG_IGNORE_SCREENEDGE) || (( (get_qr(qr_OUTOFBOUNDSENEMIES)) != bool(editorflags&ENEMY_FLAG11) ) && !NEWOUTOFBOUNDS(x,y,z+fakez)) )
1205 {
1206 //skip, it can go out of bounds, from a quest rule, or from the enemy editor (but not both!)
1207 }
1208
9/10
✓ Branch 0 taken 20750698 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 21145786 times.
✓ Branch 3 taken 1005 times.
✓ Branch 4 taken 21116075 times.
✓ Branch 5 taken 29711 times.
✓ Branch 6 taken 21116075 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 36 times.
✓ Branch 9 taken 21116039 times.
21146791 else if ( (OUTOFBOUNDS) )
1209 {
1210 30752 hp=-1000; //kill it, as it is not immortal, and no quest bit or rule is enabled
1211 30752 }
1212 //fall down
1213
6/6
✓ Branch 0 taken 13962695 times.
✓ Branch 1 taken 7185925 times.
✓ Branch 2 taken 7026915 times.
✓ Branch 3 taken 14121705 times.
✓ Branch 4 taken 338067 times.
✓ Branch 5 taken 6688848 times.
21148620 if((enemycanfall(id) || (moveflags & FLAG_OBEYS_GRAV) )&& fading != fade_flicker && clk>=0)
1214 {
1215
2/2
✓ Branch 0 taken 303574 times.
✓ Branch 1 taken 6385274 times.
6688848 if(isSideViewGravity())
1216 {
1217
1/2
✓ Branch 0 taken 303574 times.
✗ Branch 1 not taken.
303574 if(get_qr(qr_OLD_SIDEVIEW_LANDING_CODE))
1218 {
1219
2/2
✓ Branch 0 taken 176339 times.
✓ Branch 1 taken 127235 times.
303574 if(!isOnSideviewPlatform())
1220 {
1221 127235 bool willHitSVPlatform = false;
1222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH)?hit_width:16;
1223
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT)?hit_height:16;
1224
2/2
✓ Branch 0 taken 127235 times.
✓ Branch 1 taken 127235 times.
254470 for(int32_t nx = x+4; nx < x+usewid; nx+=16)
1225 {
1226
5/8
✓ Branch 0 taken 23361 times.
✓ Branch 1 taken 103874 times.
✓ Branch 2 taken 23361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23361 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 127235 times.
✗ Branch 7 not taken.
127235 if(fall > 0 && !IGNORE_SIDEVIEW_PLATFORMS && checkSVLadderPlatform(x+4,y+(fall/100)+usehei-1) && (((int32_t(y)+(int32_t(fall)/100)+usehei-1)&0xF0)!=((int32_t(y)+usehei-1)&0xF0)))
1227 {
1228 willHitSVPlatform = true;
1229 break;
1230 }
1231 127235 }
1232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 127235 times.
127235 if(willHitSVPlatform)
1233 {
1234 y+=fall/100;
1235 //y-=int32_t(y)%16; //Fix to top of SV Ladder
1236 do_fix(y, 16); //Fix to top of SV Ladder
1237 fall = 0;
1238 }
1239 else
1240 {
1241 127235 y+=fall/100;
1242
2/2
✓ Branch 0 taken 109427 times.
✓ Branch 1 taken 17808 times.
127235 if(fall <= (int32_t)zinit.terminalv)
1243 109427 fall += (zinit.gravity/100);
1244 }
1245 127235 }
1246 else
1247 {
1248
2/2
✓ Branch 0 taken 176072 times.
✓ Branch 1 taken 267 times.
176339 if(fall!=0) // Only fix pos once
1249 {
1250 //y-=(int32_t)y%8; // Fix position
1251 267 do_fix(y, 8); //Fix position
1252 267 }
1253
1254 176339 fall = 0;
1255 }
1256 303574 }
1257 else
1258 {
1259 if(isOnSideviewPlatform())
1260 fall = 0;
1261 else
1262 {
1263 zfix fall_amnt = fall/100;
1264 bool hit = false;
1265 while(fall_amnt >= 1)
1266 {
1267 --fall_amnt;
1268 ++y;
1269 if(isOnSideviewPlatform())
1270 {
1271 y = y.getInt();
1272 fall_amnt = 0;
1273 hit = true;
1274 break;
1275 }
1276 }
1277 if(fall_amnt > 0)
1278 y += fall_amnt;
1279 if(fall_amnt < 0)
1280 {
1281 if(!movexy(0,fall_amnt,spw_none))
1282 hit = true;
1283 }
1284 if(hit)
1285 fall = 0;
1286 else if(fall <= (int32_t)zinit.terminalv)
1287 fall += (zinit.gravity/100);
1288 }
1289 }
1290 303574 }
1291 else
1292 {
1293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_FAKE_Z))
1294 {
1295
2/2
✓ Branch 0 taken 3220250 times.
✓ Branch 1 taken 3165024 times.
6385274 if(fakefall!=0)
1296 3165024 fakez-=(fakefall/100);
1297
1298
2/2
✓ Branch 0 taken 3165024 times.
✓ Branch 1 taken 3220250 times.
6385274 if(fakez<0)
1299 3165024 fakez = fakefall = 0;
1300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3220250 times.
3220250 else if(fakefall <= (int32_t)zinit.terminalv)
1301 3220250 fakefall += (zinit.gravity/100);
1302
1303
5/6
✓ Branch 0 taken 6385274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3220250 times.
✓ Branch 3 taken 3165024 times.
✓ Branch 4 taken 3173265 times.
✓ Branch 5 taken 46985 times.
6385274 if (fakez<=0 && fakefall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fakefall = 0;
1304 6385274 }
1305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6385274 times.
6385274 if (!(moveflags & FLAG_NO_REAL_Z))
1306 {
1307
2/2
✓ Branch 0 taken 3486762 times.
✓ Branch 1 taken 2898512 times.
6385274 if(fall!=0)
1308 2898512 z-=(fall/100);
1309
1310
2/2
✓ Branch 0 taken 2892688 times.
✓ Branch 1 taken 3492586 times.
6385274 if(z<0)
1311 2892688 z = fall = 0;
1312
2/2
✓ Branch 0 taken 4644 times.
✓ Branch 1 taken 3487942 times.
3492586 else if(fall <= (int32_t)zinit.terminalv)
1313 3487942 fall += (zinit.gravity/100);
1314
1315
6/6
✓ Branch 0 taken 6379353 times.
✓ Branch 1 taken 5921 times.
✓ Branch 2 taken 3486665 times.
✓ Branch 3 taken 2892688 times.
✓ Branch 4 taken 3439680 times.
✓ Branch 5 taken 46985 times.
6385274 if (z<=0 && fall > 0 && !get_qr(qr_FLUCTUATING_ENEMY_JUMP)) fall = 0;
1316 6385274 }
1317
1318 }
1319 6688848 }
1320
4/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 396093 times.
✓ Branch 2 taken 5817188 times.
✓ Branch 3 taken 18007049 times.
21148620 if(!isSideViewGravity() && (moveflags & FLAG_CAN_PITFALL))
1321 {
1322
8/10
✓ Branch 0 taken 6010270 times.
✓ Branch 1 taken 11996779 times.
✓ Branch 2 taken 6003285 times.
✓ Branch 3 taken 6985 times.
✓ Branch 4 taken 6003285 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 6010270 times.
✓ Branch 8 taken 6003285 times.
✓ Branch 9 taken 6003285 times.
18007049 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1323 {
1324 6003285 fallCombo = check_pits();
1325 6003285 }
1326 30013619 }
1327
3/4
✓ Branch 0 taken 20752527 times.
✓ Branch 1 taken 8640329 times.
✓ Branch 2 taken 20752527 times.
✗ Branch 3 not taken.
12233342 if(!isSideViewGravity() && (moveflags & FLAG_CAN_WATERDROWN))
1328 {
1329 if(can_pitfall() && ((z <= 0 && fakez <= 0 && !isflier(id)) || (isflier(id) && (stunclk))) && !superman)
1330 {
1331 drownCombo = check_water();
1332 }
1333 }
1334
1335 29392856 runKnockback(); //scripted knockback handling
1336
1337 // clk is incremented here
1338
2/2
✓ Branch 0 taken 28256939 times.
✓ Branch 1 taken 1135917 times.
29392856 if(++clk >= frate)
1339 1135917 clk=0;
1340
1341 // hit and death handling
1342
2/2
✓ Branch 0 taken 28709125 times.
✓ Branch 1 taken 683731 times.
29392856 if(hclk>0)
1343 683731 --hclk;
1344
1345
2/2
✓ Branch 0 taken 28960464 times.
✓ Branch 1 taken 432392 times.
29392856 if(stunclk>0)
1346 432392 --stunclk;
1347
1/2
✓ Branch 0 taken 29392856 times.
✗ Branch 1 not taken.
29392856 if ( frozenclock > 0 )
1348 --frozenclock;
1349
1350
5/6
✓ Branch 0 taken 7002 times.
✓ Branch 1 taken 29385854 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 6947 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 55 times.
29392856 if(ceiling && z <= 0 && fakez <= 0)
1351 55 ceiling = false;
1352
1353 29392856 try_death();
1354
1355 29392856 scored=false;
1356
1357 29392856 ++c_clk;
1358
1359 //Run its script
1360
2/2
✓ Branch 0 taken 8244236 times.
✓ Branch 1 taken 21148620 times.
29392856 if (!didScriptThisFrame)
1361 {
1362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if (runscript_do_earlyret(run_script(MODE_NORMAL)))
1363 {
1364 return 0; //Avoid NULLPO if this object deleted itself
1365 }
1366 21148620 }
1367
1368 // returns true when enemy is defeated
1369 29392856 return Dead(index);
1370 29392998 }
1371
1372 21572753 bool enemy::setSolid(bool set)
1373 {
1374
1/2
✓ Branch 0 taken 21572753 times.
✗ Branch 1 not taken.
21572753 bool actual = set && !isSubmerged();
1375 21572753 bool ret = solid_object::setSolid(actual);
1376 21572753 solid = set;
1377 21572753 return ret;
1378 }
1379 void enemy::doContactDamage(int32_t hdir)
1380 {
1381 Hero.hithero(guys.find(this), hdir);
1382 }
1383
1384 3278 void enemy::solid_push(solid_object *obj)
1385 {
1386
1/2
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
3278 if(obj == this) return; //can't push self
1387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
3278 if(moveflags&FLAG_NOT_PUSHABLE) return; //not pushable
1388 3278 zfix dx, dy;
1389 3278 int32_t hdir = -1;
1390 3278 solid_push_int(obj,dx,dy,hdir,true);
1391
1392
2/4
✓ Branch 0 taken 3278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3278 times.
✗ Branch 3 not taken.
3278 if(!dx && !dy) return;
1393
1394 bool t = obj->getTempNonsolid();
1395 obj->setTempNonsolid(true);
1396
1397 int32_t ydir = dy > 0 ? down : up;
1398 int32_t xdir = dx > 0 ? right : left;
1399
1400 auto special = isflier(id) ? spw_floater : spw_none;
1401 if(!movexy(dx,dy,special,true,true))
1402 {
1403 //Crushed?
1404 }
1405
1406 obj->setTempNonsolid(t);
1407 3278 }
1408 3278 bool enemy::is_unpushable() const
1409 {
1410 3278 return isSubmerged();
1411 }
1412 3278 bool enemy::sideview_mode() const
1413 {
1414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3278 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3278 return isSideViewGravity() && (moveflags&FLAG_OBEYS_GRAV) && !(moveflags&FLAG_NOT_PUSHABLE);
1415 }
1416
1417 2559 bool enemy::m_walkflag_old(int32_t dx,int32_t dy,int32_t special, int32_t x, int32_t y)
1418 {
1419 2559 int32_t yg = (special==spw_floater)?8:0;
1420 2559 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1421
1422
8/10
✓ Branch 0 taken 1946 times.
✓ Branch 1 taken 613 times.
✓ Branch 2 taken 557 times.
✓ Branch 3 taken 56 times.
✓ Branch 4 taken 613 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 613 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1948 times.
✓ Branch 9 taken 2561 times.
2559 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1423 3894 return true;
1424
1425 2561 bool isInDungeon = isdungeon();
1426
3/4
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 2445 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 116 times.
2561 if(isInDungeon || special==spw_wizzrobe)
1427 {
1428
7/8
✓ Branch 0 taken 494 times.
✓ Branch 1 taken 1951 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 495 times.
✓ Branch 5 taken 1462 times.
✓ Branch 6 taken 495 times.
✗ Branch 7 not taken.
2445 if((x>=32 && dy<32-yg) || (y>-1000 && y<=144 && dy>=144))
1429 983 return true;
1430
1431
7/8
✓ Branch 0 taken 487 times.
✓ Branch 1 taken 975 times.
✓ Branch 2 taken 488 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 488 times.
✓ Branch 5 taken 488 times.
✓ Branch 6 taken 488 times.
✗ Branch 7 not taken.
1462 if((x>=32 && dx<32) || (x>-1000 && x<224 && dx>=224))
1432
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
976 if(special!=spw_door) // walk in door way
1433 return true;
1434 488 }
1435
1436
3/4
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 542 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
604 if(!(moveflags & FLAG_CAN_PITWALK) && !(moveflags & FLAG_CAN_PITFALL)) //Don't walk into pits (knockback doesn't call this func)
1437 {
1438
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
124 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1439
2/4
✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 62 times.
✗ Branch 3 not taken.
62 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1440 return true;
1441 62 }
1442
1443
1/4
✓ Branch 0 taken 604 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604 switch(special)
1444 {
1445 case spw_clipbottomright:
1446 if(dy>=128 || dx>=208) return true;
1447 break;
1448 case spw_clipright:
1449 break; //if(x>=208) return true; break;
1450
1451 case spw_wizzrobe: // fall through
1452 case spw_floater: // Special case for fliers and wizzrobes - hack!
1453 {
1454
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 488 times.
604 if(isInDungeon)
1455 {
1456
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dy < 32-yg || dy >= 144) return true;
1457
2/4
✓ Branch 0 taken 488 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 488 times.
488 if(dx < 32 || dx >= 224) return true;
1458 488 }
1459 604 return false;
1460 }
1461 }
1462
1463 dx&=(special==spw_halfstep)?(~7):(~15);
1464 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1465
1466 if(special==spw_water)
1467 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1468
1469 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1470 groundblocked(dx,dy+8) || groundblocked(dx+8,dy+8);
1471 613 }
1472
1473 5149 bool enemy::m_walkflag_simple(int32_t dx,int32_t dy)
1474 {
1475 5149 bool kb = false;
1476 5149 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1477
1478
5/10
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5149 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5149 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 5149 times.
5149 if(dx<16-nb || dy<zc_max(16-nb,0) || dx>=240+nb || dy>=160+nb)
1479 return true;
1480
1481
2/2
✓ Branch 0 taken 4434 times.
✓ Branch 1 taken 715 times.
5149 if(isdungeon())
1482 {
1483
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dy<32) || (dy>=144))
1484 return true;
1485
1486
2/4
✓ Branch 0 taken 715 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 715 times.
715 if((dx<32) || (dx>=224))
1487 return true;
1488 715 }
1489
1490
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
5149 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL))) //Don't walk into pits, unless being knocked back
1491 {
1492
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5149 times.
10298 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1493
2/4
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5149 times.
✗ Branch 3 not taken.
5149 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1494 return true;
1495 5149 }
1496
1497
1/2
✓ Branch 0 taken 5149 times.
✗ Branch 1 not taken.
5149 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1498 {
1499
3/4
✓ Branch 0 taken 1489 times.
✓ Branch 1 taken 3660 times.
✓ Branch 2 taken 1489 times.
✗ Branch 3 not taken.
6638 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1489 times.
1489 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1501 }
1502 else
1503 {
1504 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1505 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1506 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1507 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1508 }
1509 5149 }
1510
1511 19029446 bool enemy::m_walkflag(int32_t dx,int32_t dy,int32_t special, int32_t dir, int32_t input_x, int32_t input_y, bool kb)
1512 {
1513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19029446 times.
19029446 if(moveflags & FLAG_USE_NEW_MOVEMENT)
1514 return scr_walkflag(dx,dy,special,dir,input_x,input_y,kb);
1515 19029446 int32_t yg = (special==spw_floater)?8:0;
1516 19029446 int32_t nb = get_qr(qr_NOBORDER) ? 16 : 0;
1517
2/2
✓ Branch 0 taken 1960677 times.
✓ Branch 1 taken 17068769 times.
19029446 switch(dir)
1518 {
1519 case l_down:
1520 case r_down:
1521 case down:
1522 case 11: //r_down
1523 case 12: //down
1524 case 13: //l_down
1525 {
1526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
1960677 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1527 {
1528
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1960677 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1960677 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT && !isflier(id) )
1529 {
1530 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1531 dy += zc_max(hit_height-16,0);
1532 }
1533 1960677 }
1534 1960677 break;
1535 }
1536 }
1537
2/2
✓ Branch 0 taken 1972909 times.
✓ Branch 1 taken 17056537 times.
19029446 switch(dir)
1538 {
1539 case r_up:
1540 case r_down:
1541 case right:
1542 case 9: //r_up
1543 case 10: //right
1544 case 11: //r_down
1545 {
1546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
1972909 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
1547 {
1548
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1972909 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1972909 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH && !isflier(id) )
1549 {
1550 //Small enemies are treated as 16x16, for the purposes of m_walkflag!
1551 dx += zc_max(hit_width-16,0);
1552 }
1553 1972909 }
1554 1972909 break;
1555 }
1556 }
1557 //Z_eventlog("Checking x,y %d,%d\n",dx,dy);
1558
1559
10/10
✓ Branch 0 taken 13730315 times.
✓ Branch 1 taken 5299131 times.
✓ Branch 2 taken 4431976 times.
✓ Branch 3 taken 867155 times.
✓ Branch 4 taken 5287042 times.
✓ Branch 5 taken 12089 times.
✓ Branch 6 taken 5274023 times.
✓ Branch 7 taken 13019 times.
✓ Branch 8 taken 13757809 times.
✓ Branch 9 taken 19031832 times.
19029446 if(dx<16-nb || dy<zc_max(16-yg-nb,0) || dx>=240+nb || dy>=160+nb)
1560 27513232 return true;
1561
1562 19031832 bool isInDungeon = isdungeon();
1563
4/4
✓ Branch 0 taken 1581593 times.
✓ Branch 1 taken 17450239 times.
✓ Branch 2 taken 1123 times.
✓ Branch 3 taken 1580470 times.
19031832 if(isInDungeon || special==spw_wizzrobe)
1564 {
1565
8/8
✓ Branch 0 taken 3601717 times.
✓ Branch 1 taken 13849645 times.
✓ Branch 2 taken 3471583 times.
✓ Branch 3 taken 130134 times.
✓ Branch 4 taken 3560656 times.
✓ Branch 5 taken 10419123 times.
✓ Branch 6 taken 3560642 times.
✓ Branch 7 taken 14 times.
17451362 if((input_x>=32 && dy<32-yg) || (input_y>-1000 && input_y<=144 && dy>=144))
1566 7032225 return true;
1567
1568
8/8
✓ Branch 0 taken 3512677 times.
✓ Branch 1 taken 6906460 times.
✓ Branch 2 taken 3413625 times.
✓ Branch 3 taken 99052 times.
✓ Branch 4 taken 3480646 times.
✓ Branch 5 taken 3524866 times.
✓ Branch 6 taken 3480643 times.
✓ Branch 7 taken 3 times.
10419137 if((input_x>=32 && dx<32) || (input_x>-1000 && input_x<224 && dx>=224))
1569
2/2
✓ Branch 0 taken 66979 times.
✓ Branch 1 taken 39 times.
6894268 if(special!=spw_door) // walk in door way
1570 66979 return true;
1571 3524908 }
1572
1573
6/6
✓ Branch 0 taken 2212798 times.
✓ Branch 1 taken 2892580 times.
✓ Branch 2 taken 427580 times.
✓ Branch 3 taken 1785218 times.
✓ Branch 4 taken 34289 times.
✓ Branch 5 taken 393291 times.
5105378 if(!(moveflags & FLAG_CAN_PITWALK) && (!(moveflags & FLAG_CAN_PITFALL) || !kb)) //Don't walk into pits, unless being knocked back
1574 {
1575
3/4
✓ Branch 0 taken 2178502 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2178502 times.
4357011 if(ispitfall(dx,dy) || ispitfall(dx+8,dy)
1576
2/4
✓ Branch 0 taken 2178502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2178502 times.
✗ Branch 3 not taken.
2178502 || ispitfall(dx,dy+8) || ispitfall(dx+8,dy+8))
1577 7 return true;
1578 2178502 }
1579
1580
4/4
✓ Branch 0 taken 4093655 times.
✓ Branch 1 taken 1008118 times.
✓ Branch 2 taken 45 times.
✓ Branch 3 taken 3553 times.
5105371 switch(special)
1581 {
1582 case spw_clipbottomright:
1583
2/4
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45 times.
45 if(dy>=128 || dx>=208) return true;
1584 45 break;
1585 case spw_clipright:
1586 3553 break; //if(input_x>=208) return true; break;
1587
1588 case spw_wizzrobe: // fall through
1589 case spw_floater: // Special case for fliers and wizzrobes - hack!
1590 {
1591
2/2
✓ Branch 0 taken 1101316 times.
✓ Branch 1 taken 2992339 times.
4093655 if(isInDungeon)
1592 {
1593
3/4
✓ Branch 0 taken 2992328 times.
✓ Branch 1 taken 11 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2992328 times.
2992339 if(dy < 32-yg || dy >= 144) return true;
1594
3/4
✓ Branch 0 taken 2991477 times.
✓ Branch 1 taken 851 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2991477 times.
2992328 if(dx < 32 || dx >= 224) return true;
1595 2991477 }
1596 4092793 return false;
1597 }
1598 }
1599
1600 1011716 dx&=(special==spw_halfstep)?(~7):(~15);
1601
2/2
✓ Branch 0 taken 224029 times.
✓ Branch 1 taken 787687 times.
1011716 dy&=(special==spw_halfstep || isSideViewGravity())?(~7):(~15);
1602
1603
2/2
✓ Branch 0 taken 117322 times.
✓ Branch 1 taken 894394 times.
1011716 if(special==spw_water)
1604
2/2
✓ Branch 0 taken 8245 times.
✓ Branch 1 taken 109077 times.
117322 return (water_walkflag(dx,dy+8,1) || water_walkflag(dx+8,dy+8,1));
1605
1606
2/2
✓ Branch 0 taken 892220 times.
✓ Branch 1 taken 2174 times.
894394 if(get_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY))
1607 {
1608
4/4
✓ Branch 0 taken 666298 times.
✓ Branch 1 taken 225922 times.
✓ Branch 2 taken 660380 times.
✓ Branch 3 taken 5918 times.
1552600 return _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1609
2/2
✓ Branch 0 taken 2852 times.
✓ Branch 1 taken 657528 times.
660380 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1610 }
1611 else
1612 {
1613
4/4
✓ Branch 0 taken 1619 times.
✓ Branch 1 taken 555 times.
✓ Branch 2 taken 1607 times.
✓ Branch 3 taken 12 times.
3781 return _walkflag(dx,dy,1) || _walkflag(dx+8,dy,1) ||
1614
3/4
✓ Branch 0 taken 1599 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 1599 times.
✗ Branch 3 not taken.
1607 _walkflag(dx,dy+8,1) || _walkflag(dx+8,dy+8,1) ||
1615
3/4
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 1565 times.
✗ Branch 3 not taken.
1599 groundblocked(dx,dy,kb) || groundblocked(dx+8,dy,kb) ||
1616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1565 times.
1565 groundblocked(dx,dy+8,kb) || groundblocked(dx+8,dy+8,kb);
1617 }
1618 5314018 }
1619
1620 383430 bool enemy::isOnSideviewPlatform()
1621 {
1622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
1623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383430 times.
383430 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
1624
5/6
✓ Branch 0 taken 10306 times.
✓ Branch 1 taken 373124 times.
✓ Branch 2 taken 211 times.
✓ Branch 3 taken 10095 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 211 times.
383430 if(y + usehei >= 176 && currscr>=0x70 && !(tmpscr->flags2&wfDOWN)) return true; //Bottom of the map
1625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383219 times.
383219 if(check_slope(x, y+1, usewid, usehei)) return true;
1626
2/2
✓ Branch 0 taken 383219 times.
✓ Branch 1 taken 168001 times.
551220 for(int32_t nx = x + 4; nx <= x + usewid - 4; nx+=16)
1627 {
1628
2/2
✓ Branch 0 taken 168001 times.
✓ Branch 1 taken 215218 times.
383219 if(_walkflag(nx,y+usehei,1)) return true;
1629
3/4
✓ Branch 0 taken 168001 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120644 times.
✓ Branch 3 taken 47357 times.
168001 if(IGNORE_SIDEVIEW_PLATFORMS || ((int32_t(y)+usehei)%16)!=0) continue;
1630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 47357 times.
47357 if(checkSVLadderPlatform(nx,y+usehei)) return true;
1631 47357 }
1632 168001 return false;
1633 383430 }
1634
1635 // Stops playing the given sound only if there are no enemies left to play it
1636 451658 void enemy::stop_bgsfx(int32_t index)
1637 {
1638
2/2
✓ Branch 0 taken 441954 times.
✓ Branch 1 taken 9704 times.
451658 if(bgsfx<=0)
1639 441954 return;
1640
1641 // Look for other enemies with the same bgsfx
1642
2/2
✓ Branch 0 taken 39307 times.
✓ Branch 1 taken 5718 times.
45025 for(int32_t i=0; i<guys.Count(); i++)
1643 {
1644
4/4
✓ Branch 0 taken 32357 times.
✓ Branch 1 taken 6950 times.
✓ Branch 2 taken 3986 times.
✓ Branch 3 taken 28371 times.
39307 if(i!=index && ((enemy*)guys.spr(i))->bgsfx==bgsfx)
1645 3986 return;
1646 35321 }
1647
1648 5718 stop_sfx(bgsfx);
1649 451658 }
1650
1651
1652 // to allow for different sfx on defeating enemy
1653 21658 void enemy::death_sfx()
1654 {
1655
2/2
✓ Branch 0 taken 21634 times.
✓ Branch 1 taken 24 times.
21658 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
1656 21658 }
1657
1658 void enemy::move(zfix dx,zfix dy)
1659 {
1660 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1661 {
1662 switch(family)
1663 {
1664 case eeFIRE:
1665 case eeOTHER:
1666 return;
1667 default: break;
1668 }
1669 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1670 }
1671 */
1672 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV) || !enemycanfall(id)))
1673 {
1674 x+=dx;
1675 y+=dy;
1676 }
1677 }
1678
1679 10385398 void enemy::move(zfix s)
1680 {
1681 /*if(FFCore.getQuestHeaderInfo(vZelda) >= 0x255 && FFCore.getQuestHeaderInfo(vBuild) >= 50 )
1682 {
1683 switch(family)
1684 {
1685 case eeFIRE:
1686 case eeOTHER:
1687 return;
1688 default: break;
1689 }
1690 if(family >= eeSCRIPT01 && family <= eeFFRIENDLY10 ) return;
1691 }*/
1692
9/10
✓ Branch 0 taken 10385359 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 79762 times.
✓ Branch 3 taken 10305597 times.
✓ Branch 4 taken 40724 times.
✓ Branch 5 taken 39038 times.
✓ Branch 6 taken 855 times.
✓ Branch 7 taken 39869 times.
✓ Branch 8 taken 855 times.
✗ Branch 9 not taken.
10385398 if(!watch && (!(isSideViewGravity()) || isOnSideviewPlatform() || !enemycanfall(id) || !(moveflags & FLAG_OBEYS_GRAV)))
1693 {
1694 10384504 sprite::move(s);
1695 10384504 }
1696 10385398 }
1697
1698 24760 void enemy::leave_item()
1699 {
1700 24760 int32_t drop_item = select_dropitem(item_set, x, y);
1701 24760 int32_t thedropset = item_set;
1702
1703 24760 std::vector<int32_t> &ev = FFCore.eventData;
1704 24760 ev.clear();
1705 24760 ev.push_back(getUID());
1706 24760 ev.push_back(drop_item*10000);
1707 24760 ev.push_back(thedropset*10000);
1708
1709 24760 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_1);
1710 24760 drop_item = vbound(ev[1] / 10000,-2,255);
1711 24760 thedropset = ev[2] / 10000;
1712 24760 ev.clear();
1713
1/2
✓ Branch 0 taken 24760 times.
✗ Branch 1 not taken.
24760 if(drop_item == -2)
1714 {
1715 drop_item = select_dropitem(thedropset,x,y);
1716 }
1717
1718
6/6
✓ Branch 0 taken 9759 times.
✓ Branch 1 taken 15001 times.
✓ Branch 2 taken 563 times.
✓ Branch 3 taken 9196 times.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 414 times.
24760 if(drop_item>=0&&((itemsbuf[drop_item].family!=itype_fairy)||!m_walkflag(x,y,0,dir)))
1719 {
1720 item* itm;
1721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9610 times.
9610 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
1722 {
1723 itm = (new item(x+hxofs+(hit_width/2)-8,y+hyofs+(hit_height/2)-8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1724 }
1725 else
1726 {
1727
8/14
✓ Branch 0 taken 1436 times.
✓ Branch 1 taken 8174 times.
✓ Branch 2 taken 1436 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1436 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1436 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1436 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1436 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1436 times.
✗ Branch 13 not taken.
9610 if(extend >= 3) itm = (new item(x+(txsz-1)*8,y+(tysz-1)*8,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1728
4/8
✓ Branch 0 taken 8174 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8174 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8174 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8174 times.
✗ Branch 7 not taken.
8174 else itm = (new item(x,y,(zfix)0,drop_item,ipBIGRANGE+ipTIMER,0));
1729 }
1730 9610 itm->from_dropset = thedropset;
1731 9610 items.add(itm);
1732
1733 9610 ev.push_back(getUID());
1734 9610 ev.push_back(itm->getUID());
1735
1736 9610 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DROP_ITEM_2);
1737 9610 ev.clear();
1738 9610 }
1739 24760 }
1740
1741 // auomatically kill off enemy (for rooms with ringleaders)
1742 344 void enemy::kickbucket()
1743 {
1744
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 32 times.
344 if(!superman)
1745 312 hp=-1000; // don't call death_sfx()
1746 344 }
1747
1748 3278 bool enemy::isSubmerged() const
1749 {
1750 3278 return submerged;
1751 //!TODO SOLIDPUSH more things like teleporting wizzrobes
1752 }
1753
1754 17408 void enemy::FireBreath(bool seekhero)
1755 {
1756
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(wpn==wNone)
1757 return;
1758
1759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17408 times.
17408 if(wpn==ewFireTrail)
1760 {
1761 dmisc1 = e1tEACHTILE;
1762 FireWeapon();
1763 return;
1764 }
1765
1766 17408 float fire_angle=0.0;
1767 17408 int32_t wx=0, wy=0, wdir=dir;
1768
1769
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 if(!seekhero)
1770 {
1771
4/5
✓ Branch 0 taken 3271 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3038 times.
✓ Branch 3 taken 5264 times.
✓ Branch 4 taken 4131 times.
15704 switch(dir)
1772 {
1773 case down:
1774 3038 fire_angle=PI*(int64_t(zc_oldrand()%20)+10)/40;
1775 3038 wx=x;
1776 3038 wy=y+8;
1777 3038 break;
1778
1779 case -1:
1780 case up:
1781 3271 fire_angle=PI*(int64_t(zc_oldrand()%20)+50)/40;
1782 3271 wx=x;
1783 3271 wy=y-8;
1784 3271 break;
1785
1786 case left:
1787 5264 fire_angle=PI*(int64_t(zc_oldrand()%20)+30)/40;
1788 5264 wx=x-8;
1789 5264 wy=y;
1790 5264 break;
1791
1792 case right:
1793 4131 fire_angle=PI*(int64_t(zc_oldrand()%20)+70)/40;
1794 4131 wx=x+8;
1795 4131 wy=y;
1796 4131 break;
1797 }
1798
1799
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
15704 if(wpn==ewFlame || wpn==ewFlame2)
1800 {
1801
2/4
✓ Branch 0 taken 15704 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15704 times.
15704 if(fire_angle==-PI || fire_angle==PI) wdir=left;
1802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==-PI/2) wdir=up;
1803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==PI/2) wdir=down;
1804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle==0) wdir=right;
1805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<-PI/2) wdir=l_up;
1806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15704 times.
15704 else if(fire_angle<0) wdir=r_up;
1807
2/2
✓ Branch 0 taken 1498 times.
✓ Branch 1 taken 14206 times.
15704 else if(fire_angle<(PI/2)) wdir=r_down;
1808
2/2
✓ Branch 0 taken 10090 times.
✓ Branch 1 taken 4116 times.
14206 else if(fire_angle<PI) wdir=l_down;
1809 15704 }
1810 15704 }
1811 else
1812 {
1813 1704 wx = x;
1814 1704 wy = y;
1815 }
1816
1817
2/2
✓ Branch 0 taken 1704 times.
✓ Branch 1 taken 15704 times.
17408 addEwpn(wx,wy,z,wpn,2,wdp,seekhero ? 0xFF : wdir, getUID(), 0, fakez);
1818 17408 sfx(wpnsfx(wpn),pan(int32_t(x)));
1819
1820 17408 int32_t i=Ewpns.Count()-1;
1821 17408 weapon *ew = (weapon*)(Ewpns.spr(i));
1822 17408 ew->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1823
1824
4/4
✓ Branch 0 taken 15704 times.
✓ Branch 1 taken 1704 times.
✓ Branch 2 taken 7830 times.
✓ Branch 3 taken 7874 times.
17408 if(!seekhero && (zc_oldrand()&4))
1825 {
1826 7874 ew->angular=true;
1827 7874 ew->angle=fire_angle;
1828 7874 }
1829
1830
4/4
✓ Branch 0 taken 17351 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 17034 times.
17408 if(wpn==ewFlame && wpnsbuf[ewFLAME].frames>1)
1831 {
1832 17034 ew->aframe=zc_oldrand()%wpnsbuf[ewFLAME].frames;
1833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17034 times.
17034 if ( ew->do_animation ) ew->tile+=ew->aframe;
1834 17034 }
1835
1836
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 543348 times.
560756 for(int32_t j=Ewpns.Count()-1; j>0; j--)
1837 {
1838 543348 Ewpns.swap(j,j-1);
1839 543348 }
1840 17408 }
1841
1842 28308 void enemy::FireWeapon()
1843 {
1844 /*
1845 * Type:
1846 * 0x01: Boss fireball
1847 * 0x02: Seeks Hero
1848 * 0x04: Fast projectile
1849 * 0x00-0x30: If 0x02, slants toward (type>>3)-1
1850 */
1851
1852
2/2
✓ Branch 0 taken 28298 times.
✓ Branch 1 taken 10 times.
28308 if (wpn < 1) return;
1853
1/10
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
28298 if(wpn<wEnemyWeapons && dmisc1!=9 && dmisc1!=10 && (wpn < wScript1 && wpn > wScript10) ) // Summoning doesn't require weapons
1854 return;
1855
1856
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 28298 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28298 if(wpn==ewFireTrail && dmisc1>=e1t3SHOTS && dmisc1<=e1t8SHOTS)
1857 dmisc1 = e1tEACHTILE;
1858
1859 28298 int32_t xoff = 0;
1860 28298 int32_t yoff = 0;
1861
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
1862 {
1863 xoff += (hit_width/2)-8;
1864 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
1865 }
1866
1/2
✓ Branch 0 taken 28298 times.
✗ Branch 1 not taken.
28298 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
1867 {
1868 yoff += (hit_height/2)-8;
1869 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
1870 }
1871
1872
4/8
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 26887 times.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 409 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28298 switch(dmisc1)
1873 {
1874 case e1t5SHOTS: //BS-Aquamentus
1875 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+5)<<3),wdp,dir,-1, getUID(),false));
1876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+5)<<3),wdp,dir,-1, getUID(),false));
1878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1879
1880 [[fallthrough]];
1881 case e1t3SHOTSFAST:
1882 case e1t3SHOTS: //Aquamentus
1883
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^left)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1884 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1885
7/14
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 413 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 413 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 413 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 413 times.
✗ Branch 13 not taken.
413 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^right)+1)<<3)+(dmisc1==e1t3SHOTSFAST ? 4:0),wdp,dir,-1, getUID(),false));
1886 413 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1887
1888 [[fallthrough]];
1889 default:
1890
11/20
✓ Branch 0 taken 27300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 27300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 27300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 27300 times.
✓ Branch 12 taken 27300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11345 times.
✓ Branch 15 taken 15955 times.
✓ Branch 16 taken 27300 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 27300 times.
✗ Branch 19 not taken.
27300 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(dmisc1==e1t3SHOTSFAST || dmisc1==e1tFAST ? 4:0),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1891 27300 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1892 27300 sfx(wpnsfx(wpn),pan(int32_t(x)));
1893 27300 break;
1894
1895 case e1tSLANT:
1896 {
1897 409 int32_t slant = 0;
1898
1899
10/10
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 304 times.
✓ Branch 2 taken 197 times.
✓ Branch 3 taken 212 times.
✓ Branch 4 taken 45 times.
✓ Branch 5 taken 152 times.
✓ Branch 6 taken 60 times.
✓ Branch 7 taken 304 times.
✓ Branch 8 taken 131 times.
✓ Branch 9 taken 173 times.
409 if(((Hero.x-x) < -8 && dir==up) || ((Hero.x-x) > 8 && dir==down) || ((Hero.y-y) < -8 && dir==left) || ((Hero.y-y) > 8 && dir==right))
1900 236 slant = left;
1901
10/10
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 29 times.
✓ Branch 6 taken 51 times.
✓ Branch 7 taken 85 times.
✓ Branch 8 taken 24 times.
✓ Branch 9 taken 61 times.
173 else if(((Hero.x-x) > 8 && dir==up) || ((Hero.x-x) < -8 && dir==down) || ((Hero.y-y) > 8 && dir==left) || ((Hero.y-y) < -8 && dir==right))
1902 112 slant = right;
1903
1904
9/18
✓ Branch 0 taken 319 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 319 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 319 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 319 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 319 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 319 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 319 times.
✓ Branch 14 taken 319 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 319 times.
✗ Branch 17 not taken.
319 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,2+(((dir^slant)+1)<<3),wdp,wpn==ewFireball2 || wpn==ewFireball ? 0:dir,-1, getUID(),false));
1905 319 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1906 319 sfx(wpnsfx(wpn),pan(int32_t(x)));
1907 319 break;
1908 }
1909
1910 case e1t8SHOTS: //Fire Wizzrobe
1911 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_up,-1, getUID(),false));
1912 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1913 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1914 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,l_down,-1, getUID(),false));
1915 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1916 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1917 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_up,-1, getUID(),false));
1918 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1919 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1920 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,r_down,-1, getUID(),false));
1921 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1922 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1923
1924 [[fallthrough]];
1925 case e1t4SHOTS: //Stalfos 3
1926
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,up,-1, getUID(),false));
1927 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1928 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1929
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,down,-1, getUID(),false));
1930 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1931 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1932
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,left,-1, getUID(),false));
1933 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1934 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1935
7/14
✓ Branch 0 taken 589 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 589 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 589 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 589 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 589 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 589 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 589 times.
✗ Branch 13 not taken.
589 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,0,wdp,right,-1, getUID(),false));
1936 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
1937 589 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
1938 589 sfx(wpnsfx(wpn),pan(int32_t(x)));
1939 589 break;
1940
1941 case e1tSUMMON: // Bat Wizzrobe
1942 {
1943 //al_trace("Summon Bats\n");
1944 //zprint2("Summon Bats\n");
1945 if(dmisc4==0) break; // Summon 0
1946
1947 int32_t bc=0;
1948
1949 for(int32_t gc=0; gc<guys.Count(); gc++)
1950 {
1951 if((((enemy*)guys.spr(gc))->id) == dmisc3)
1952 {
1953 ++bc;
1954 }
1955 }
1956
1957 if(bc<=40) // Not too many enemies
1958 {
1959 int32_t kids = guys.Count();
1960 int32_t bats=(zc_oldrand()%zc_max(1,dmisc4))+1;
1961
1962 for(int32_t i=0; i<bats; i++)
1963 {
1964 //zprint2("summon\n");
1965 //al_trace("summon\n");
1966 if(addchild(x,y,dmisc3,-10, this->script_UID))
1967 {
1968 ((enemy*)guys.spr(kids+i))->count_enemy = false;
1969 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
1970 //zprint2("Summoner Script UID: %d\n",this->script_UID);
1971
1972 }
1973 }
1974
1975 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
1976 }
1977
1978 break;
1979 }
1980
1981 case e1tSUMMONLAYER: // Summoner
1982 {
1983 if(count_layer_enemies()==0)
1984 {
1985 break;
1986 }
1987
1988 int32_t kids = guys.Count();
1989
1990 if(kids<40)
1991 {
1992 int32_t newguys=(zc_oldrand()%3)+1;
1993 bool summoned=false;
1994
1995 for(int32_t i=0; i<newguys; i++)
1996 {
1997 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
1998 int32_t x2=0;
1999 int32_t y2=0;
2000
2001 for(int32_t k=0; k<20; ++k)
2002 {
2003 x2=16*((zc_oldrand()%12)+2);
2004 y2=16*((zc_oldrand()%7)+2);
2005
2006 if((!m_walkflag(x2,y2,0,dir))&&((abs(x2-Hero.getX())>=32)||(abs(y2-Hero.getY())>=32)))
2007 {
2008 //zprint2("summon\n");
2009 //al_trace("summon\n");
2010 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
2011 {
2012 ((enemy*)guys.spr(kids+i))->count_enemy = false;
2013 //((enemy*)guys.spr(guys.Count()-1))->parent_script_UID = this->script_UID;
2014 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
2015 {
2016 ((enemy*)guys.spr(kids+i))->fakez = 64;
2017 ((enemy*)guys.spr(kids+i))->z = 0;
2018 }
2019 }
2020
2021 summoned=true;
2022 break;
2023 }
2024 }
2025 }
2026
2027 if(summoned)
2028 {
2029 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2030 }
2031 }
2032
2033 break;
2034 }
2035 }
2036 28218 }
2037
2038
2039 // Hit the shield(s)?
2040 // Apparently, this function is only used for hookshots...
2041 398 bool enemy::hitshield(int32_t wpnx, int32_t wpny, int32_t xdir)
2042 {
2043
4/6
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 292 times.
✓ Branch 2 taken 106 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 106 times.
398 if(!(family==eeWALK || family==eeFIRE || family==eeOTHER))
2044 106 return false;
2045
2046 292 bool ret = false;
2047
2048 // TODO: There must be some bitwise operations that can simplify this...
2049
9/12
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 155 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 123 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 6 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 129 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 129 times.
✓ Branch 10 taken 129 times.
✗ Branch 11 not taken.
292 if(wpny > y) ret = ((flags&inv_front && xdir==down) || (flags&inv_back && xdir==up) || (flags&inv_left && xdir==left) || (flags&inv_right && xdir==right));
2050
9/12
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 82 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
155 else if(wpny < y) ret = ((flags&inv_front && xdir==up) || (flags&inv_back && xdir==down) || (flags&inv_left && xdir==right) || (flags&inv_right && xdir==left));
2051
2052
11/14
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 185 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 95 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 6 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 101 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 101 times.
✓ Branch 12 taken 101 times.
✗ Branch 13 not taken.
300 if(wpnx < x) ret = ret || ((flags&inv_front && xdir==left) || (flags&inv_back && xdir==right) || (flags&inv_left && xdir==up) || (flags&inv_right && xdir==down));
2053
10/14
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 145 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 144 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 141 times.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 141 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 141 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 141 times.
185 else if(wpnx > x) ret = ret || ((flags&inv_front && xdir==right) || (flags&inv_back && xdir==left) || (flags&inv_left && xdir==down) || (flags&inv_right && xdir==up));
2054
2055 300 return ret;
2056 406 }
2057
2058
2059 //! Weapon Editor for 2.6
2060 //To hell with this. I'm writing new functions to resolve weapon type and defence. -Z
2061
2062
2063 //converts a wqeapon ID to its defence index.
2064 73090 int32_t weaponToDefence(int32_t wid)
2065 {
2066
20/44
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 32485 times.
✓ Branch 3 taken 6764 times.
✓ Branch 4 taken 18964 times.
✓ Branch 5 taken 702 times.
✓ Branch 6 taken 28 times.
✓ Branch 7 taken 48 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 1549 times.
✓ Branch 10 taken 7171 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 163 times.
✓ Branch 14 taken 1166 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✓ Branch 17 taken 322 times.
✓ Branch 18 taken 920 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 866 times.
✓ Branch 21 taken 406 times.
✓ Branch 22 taken 118 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 325 times.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✓ Branch 29 taken 11 times.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✓ Branch 33 taken 12 times.
✓ Branch 34 taken 77 times.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 993 times.
✗ Branch 41 not taken.
✗ Branch 42 not taken.
✗ Branch 43 not taken.
73090 switch(wid)
2067 {
2068 case wNone: return -1;
2069 32485 case wSword: return edefSWORD;
2070 6764 case wBeam: return edefBEAM;
2071 18964 case wBrang: return edefBRANG;
2072 702 case wBomb: return edefBOMB;
2073 28 case wSBomb: return edefSBOMB;
2074 48 case wLitBomb: return edefBOMB;
2075 case wLitSBomb: return edefSBOMB;
2076 1549 case wArrow: return edefARROW;
2077 7171 case wFire: return edefFIRE;
2078 case wWhistle:
2079 {
2080 //al_trace("Weapon resolved as a whistle, using edef: %s\n", "edefWhistle");
2081 return edefWhistle;
2082 }
2083 case wBait: return edefBAIT;
2084 163 case wWand: return edefWAND;
2085 1166 case wMagic: return edefMAGIC;
2086 case wCatching: return -1;
2087 case wWind: return edefWIND;
2088 322 case wRefMagic: return edefREFMAGIC;
2089 920 case wRefFireball: return edefREFBALL;
2090 case wRefRock: return edefREFROCK;
2091 866 case wHammer: return edefHAMMER;
2092 406 case wHookshot: return edefHOOKSHOT;
2093 118 case wHSHandle: return edefHOOKSHOT;
2094 case wHSChain: return edefHOOKSHOT;
2095 case wSSparkle: return edefSPARKLE;
2096 325 case wFSparkle: return edefSPARKLE;
2097 case wSmack: return -1; // is this the candle object?
2098 case wPhantom: return -1; //engine created visual effects.
2099 case wCByrna: return edefBYRNA;
2100 11 case wRefBeam: return edefREFBEAM;
2101 case wStomp: return edefSTOMP;
2102 case wScript1: return edefSCRIPT01;
2103 case wScript2: return edefSCRIPT02;
2104 12 case wScript3: return edefSCRIPT03;
2105 77 case wScript4: return edefSCRIPT04;
2106 case wScript5: return edefSCRIPT05;
2107 case wScript6: return edefSCRIPT06;
2108 case wScript7: return edefSCRIPT07;
2109 case wScript8: return edefSCRIPT08;
2110 case wScript9: return edefSCRIPT09;
2111 993 case wScript10: return edefSCRIPT10;
2112 case wIce: return edefICE;
2113 case wSound: return edefSONIC;
2114 case wThrown: return edefTHROWN;
2115 //case wPot: return edefPOT;
2116 // case wLitZap: return edefELECTRIC;
2117 // case wZ3Sword: return edefZ3SWORD;
2118 // case wLASWord: return edefLASWORD;
2119 // case wSpinAttk: return edefSPINATTK;
2120 // case wShield: return edefSHIELD;
2121 // case wTrowel: return edefTROWEL;
2122
2123 default: return -1;
2124 }
2125 73090 }
2126
2127 73090 int32_t getDefType(weapon *w)
2128 {
2129 73090 int32_t id = getWeaponID(w);
2130 73090 int32_t edef = weaponToDefence(id);
2131
2/2
✓ Branch 0 taken 72566 times.
✓ Branch 1 taken 524 times.
73090 if(edef == edefHOOKSHOT)
2132 {
2133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 524 times.
524 if(w->family_class == itype_switchhook)
2134 return edefSwitchHook;
2135 524 }
2136 73090 return edef;
2137 73090 }
2138
2139 126810 int32_t getWeaponID(weapon *w)
2140 {
2141 126810 int32_t usewpn = w->useweapon;
2142
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126810 times.
126810 return (usewpn > 0) ? usewpn : w->id;
2143 }
2144
2145 73090 int32_t enemy::resolveEnemyDefence(weapon *w)
2146 {
2147 //sword edef is 9, but we're reading it at 0
2148 //,
2149 73090 int32_t weapondef = 0;
2150 73090 int32_t wdeftype = getDefType(w);
2151 73090 int32_t usedef = w->usedefence;
2152
2153
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
73090 if ( usedef > 0 && (wdeftype < 0 || wdeftype >= edefLAST255 || defense[wdeftype] == 0))
2154 {
2155 weapondef = usedef*-1;
2156 }
2157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73090 times.
73090 else if(unsigned(wdeftype) < edefLAST255)
2158 {
2159 73090 weapondef = wdeftype;
2160 73090 }
2161 73090 return weapondef;
2162 }
2163
2164 79108 byte get_def_ignrflag(int32_t edef)
2165 {
2166
3/3
✓ Branch 0 taken 66047 times.
✓ Branch 1 taken 2329 times.
✓ Branch 2 taken 10732 times.
79108 switch(edef)
2167 {
2168 case edIGNORE:
2169 case edIGNOREL1:
2170 case edSTUNORIGNORE:
2171 10732 return WPNUNB_IGNR;
2172 case edSTUNORCHINK:
2173 case edCHINK:
2174 case edCHINKL1:
2175 case edCHINKL2:
2176 case edCHINKL4:
2177 case edCHINKL6:
2178 case edCHINKL8:
2179 case edCHINKL10:
2180 case edLEVELCHINK2:
2181 case edLEVELCHINK3:
2182 case edLEVELCHINK4:
2183 case edLEVELCHINK5:
2184 2329 return WPNUNB_BLOCK;
2185 }
2186 66047 return 0;
2187 79108 }
2188
2189 79108 int32_t conv_edef_unblockable(int32_t edef, byte unblockable)
2190 {
2191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79108 times.
79108 if(!(unblockable&get_def_ignrflag(edef))) return edef;
2192 switch(edef)
2193 {
2194 case edIGNORE:
2195 case edIGNOREL1:
2196 case edCHINK:
2197 case edCHINKL1:
2198 case edCHINKL2:
2199 case edCHINKL4:
2200 case edCHINKL6:
2201 case edCHINKL8:
2202 case edCHINKL10:
2203 case edLEVELCHINK2:
2204 case edLEVELCHINK3:
2205 case edLEVELCHINK4:
2206 case edLEVELCHINK5:
2207 return edNORMAL;
2208 case edSTUNORIGNORE:
2209 case edSTUNORCHINK:
2210 return edSTUNONLY;
2211 }
2212 return edef;
2213 79108 }
2214
2215 // Do we do damage?
2216 // 0: takehit returns 0
2217 // 1: takehit returns 1
2218 // -1: do damage
2219 //The input from resolveEnemyDefence() for the param 'edef' is negative if a specific defence RESULT is being used.
2220 72097 int32_t enemy::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable) //May need *wpn to set return on brangs and hookshots
2221 {
2222
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(switch_hooked) return 0;
2223 72097 int32_t tempx = x;
2224 72097 int32_t tempy = y;
2225 72097 int32_t the_defence = 0;
2226
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if ( edef < 0 ) //we are using a specific base default defence for a weapon
2227 {
2228 the_defence = edef*-1; //A specific defence type.
2229 }
2230 72097 else the_defence = defense[edef];
2231
2232 72097 the_defence = conv_edef_unblockable(the_defence, unblockable);
2233
2234
3/4
✓ Branch 0 taken 4350 times.
✓ Branch 1 taken 67747 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4350 times.
72097 if(shieldCanBlock && !(unblockable&WPNUNB_SHLD))
2235 {
2236
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 4343 times.
✓ Branch 2 taken 7 times.
4350 switch(the_defence)
2237 {
2238 case edIGNORE:
2239 7 return 0;
2240 case edIGNOREL1:
2241 case edSTUNORIGNORE:
2242 if(*power <= 0)
2243 return 0;
2244 }
2245 4343 sfx(WAV_CHINK,pan(int32_t(x)));
2246 4343 return 1;
2247 }
2248
2249 67747 int32_t new_id = id;
2250 67747 int32_t effect_type = dmisc15;
2251 67747 int32_t delay_timer = 90;
2252 67747 enemy *gleeok = NULL;
2253 67747 enemy *ptra = NULL;
2254 67747 int32_t c = 0;
2255
2256
15/29
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 322 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1413 times.
✓ Branch 6 taken 902 times.
✓ Branch 7 taken 21 times.
✓ Branch 8 taken 80 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 199 times.
✓ Branch 13 taken 9312 times.
✓ Branch 14 taken 173 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1789 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 71 times.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✓ Branch 25 taken 79 times.
✓ Branch 26 taken 58 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 53312 times.
67747 switch(the_defence)
2257 {
2258 case edREPLACE:
2259 {
2260 sclk = 0;
2261 if ( dmisc16 > 0 ) new_id = dmisc16;
2262 else new_id = id+1;
2263 if ( new_id > 511 ) new_id = id; //Sanity bound to legal enemy IDs.
2264 if ( dmisc17 > 0 ) delay_timer = dmisc17;
2265 //if ( dmisc18 > 0 ) dummy_wpn_id = dmisc18;
2266
2267 //Z_scripterrlog("new id is %d\n", new_id);
2268 switch(guysbuf[new_id&0xFFF].family)
2269 {
2270 //Fixme: possible enemy memory leak. (minor)
2271 case eeWALK:
2272 {
2273 enemy *e = new eStalfos(x,y,new_id,clk);
2274 guys.add(e);
2275 }
2276 break;
2277
2278 case eeLEV:
2279 {
2280 enemy *e = new eLeever(x,y,new_id,clk);
2281 guys.add(e);
2282 }
2283 break;
2284
2285 case eeTEK:
2286 {
2287 enemy *e = new eTektite(x,y,new_id,clk);
2288 guys.add(e);
2289 }
2290 break;
2291
2292 case eePEAHAT:
2293 {
2294 enemy *e = new ePeahat(x,y,new_id,clk);
2295 guys.add(e);
2296 }
2297 break;
2298
2299 case eeZORA:
2300 {
2301 enemy *e = new eZora(x,y,new_id,clk);
2302 guys.add(e);
2303 }
2304 break;
2305
2306 case eeGHINI:
2307 {
2308 enemy *e = new eGhini(x,y,new_id,clk);
2309 guys.add(e);
2310 }
2311 break;
2312
2313 case eeKEESE:
2314 {
2315 enemy *e = new eKeese(x,y,new_id,clk);
2316 guys.add(e);
2317 }
2318 break;
2319
2320 case eeWIZZ:
2321 {
2322 enemy *e = new eWizzrobe(x,y,new_id,clk);
2323 guys.add(e);
2324 }
2325 break;
2326
2327 case eePROJECTILE:
2328 {
2329 enemy *e = new eProjectile(x,y,new_id,clk);
2330 guys.add(e);
2331 }
2332 break;
2333
2334 case eeWALLM:
2335 {
2336 enemy *e = new eWallM(x,y,new_id,clk);
2337 guys.add(e);
2338 }
2339 break;
2340
2341 case eeAQUA:
2342 {
2343 enemy *e = new eAquamentus(x,y,new_id,clk);
2344 guys.add(e);
2345 e->x = x;
2346 e->y = y;
2347 }
2348 break;
2349
2350 case eeMOLD:
2351 {
2352 enemy *e = new eMoldorm(x,y,new_id,zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1)));
2353 guys.add(e);
2354 e->x = x;
2355 e->y = y;
2356 }
2357 break;
2358
2359 case eeMANHAN:
2360 {
2361 enemy *e = new eManhandla(x,y,new_id,clk);
2362 guys.add(e);
2363 e->x = x;
2364 e->y = y;
2365 }
2366 break;
2367
2368 case eeGLEEOK:
2369 {
2370 *power = 0;
2371 gleeok = new eGleeok(x,y,new_id,guysbuf[new_id&0xFFF].misc1);
2372 guys.add(gleeok);
2373 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2374 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2375 new_id &= 0xFFF;
2376 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2377 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2378 for(int32_t i=0; i<head_cnt; i++)
2379 {
2380 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2381 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2382 {
2383 al_trace("Gleeok head %d could not be created!\n",i+1);
2384
2385 for(int32_t j=0; j<i+1; j++)
2386 {
2387 guys.del(guys.Count()-1);
2388 }
2389
2390 break;
2391 }
2392 else
2393 {
2394 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2395 //((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2396 }
2397
2398 c-=guysbuf[new_id].misc4;
2399 //gleeok->x = x;
2400 //gleeok->y = y;
2401 //gleeok = e;
2402 }
2403 return 1;
2404 }
2405
2406 case eeGHOMA:
2407 {
2408 enemy *e = new eGohma(x,y,new_id,clk);
2409 guys.add(e);
2410 e->x = x;
2411 e->y = y;
2412 }
2413 break;
2414
2415 case eeLANM:
2416 {
2417 enemy *e = new eLanmola(x,y,new_id,zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)));
2418 guys.add(e);
2419 e->x = x;
2420 e->y = y;
2421 }
2422 break;
2423
2424 case eeGANON:
2425 {
2426 enemy *e = new eGanon(x,y,new_id,clk);
2427 guys.add(e);
2428 e->x = x;
2429 e->y = y;
2430 }
2431 break;
2432
2433 case eeFAIRY:
2434 {
2435 enemy *e = new eItemFairy(x,y,new_id+0x1000*clk,clk);
2436 guys.add(e);
2437 e->x = x;
2438 e->y = y;
2439 }
2440 break;
2441
2442 case eeFIRE:
2443 {
2444 enemy *e = new eFire(x,y,new_id,clk);
2445 guys.add(e);
2446 e->x = x;
2447 e->y = y;
2448 }
2449 break;
2450
2451 case eeOTHER:
2452 {
2453 enemy *e = new eOther(x,y,new_id,clk);
2454 guys.add(e);
2455 e->x = x;
2456 e->y = y;
2457 }
2458 break;
2459
2460 case eeSPINTILE:
2461 {
2462 enemy *e = new eSpinTile(x,y,new_id,clk);
2463 guys.add(e);
2464 e->x = x;
2465 e->y = y;
2466 }
2467 break;
2468
2469 // and these enemies use the misc10/misc2 value
2470 case eeROCK:
2471 {
2472 switch(guysbuf[new_id&0xFFF].misc10)
2473 {
2474 case 1:
2475 {
2476 enemy *e = new eBoulder(x,y,new_id,clk);
2477 guys.add(e);
2478 e->x = x;
2479 e->y = y;
2480 }
2481 break;
2482
2483 case 0:
2484 default:
2485 {
2486 enemy *e = new eRock(x,y,new_id,clk);
2487 guys.add(e);
2488 e->x = x;
2489 e->y = y;
2490 }
2491 break;
2492 }
2493
2494 break;
2495 }
2496
2497 case eeTRAP:
2498 {
2499 switch(guysbuf[new_id&0xFFF].misc2)
2500 {
2501 case 1:
2502 {
2503 enemy *e = new eTrap2(x,y,new_id,clk);
2504 guys.add(e);
2505 e->x = x;
2506 e->y = y;
2507 }
2508 break;
2509
2510 case 0:
2511 default:
2512 {
2513 enemy *e = new eTrap(x,y,new_id,clk);
2514 guys.add(e);
2515 e->x = x;
2516 e->y = y;
2517 }
2518 break;
2519 }
2520
2521 break;
2522 }
2523
2524 case eeDONGO:
2525 {
2526 switch(guysbuf[new_id&0xFFF].misc10)
2527 {
2528 case 1:
2529 {
2530 enemy *e = new eDodongo2(x,y,new_id,clk);
2531 guys.add(e);
2532 e->x = x;
2533 e->y = y;
2534 }
2535 break;
2536
2537 case 0:
2538 default:
2539 {
2540 enemy *e = new eDodongo(x,y,new_id,clk);
2541 guys.add(e);
2542 e->x = x;
2543 e->y = y;
2544 }
2545 break;
2546 }
2547
2548 break;
2549 }
2550
2551 case eeDIG:
2552 {
2553 switch(guysbuf[new_id&0xFFF].misc10)
2554 {
2555 case 1:
2556 {
2557 enemy *e = new eLilDig(x,y,new_id,clk);
2558 guys.add(e);
2559 e->x = x;
2560 e->y = y;
2561 }
2562 break;
2563
2564 case 0:
2565 default:
2566 {
2567 enemy *e = new eBigDig(x,y,new_id,clk);
2568 guys.add(e);
2569 e->x = x;
2570 e->y = y;
2571 }
2572 break;
2573 }
2574
2575 break;
2576 }
2577
2578 case eePATRA:
2579 {
2580 switch(guysbuf[new_id&0xFFF].misc10)
2581 {
2582 case 1:
2583 {
2584 if (get_qr(qr_HARDCODED_BS_PATRA))
2585 {
2586 enemy *e = new ePatraBS(x,y,new_id,clk);
2587 guys.add(e);
2588 e->x = x;
2589 e->y = y;
2590 break;
2591 }
2592 }
2593 [[fallthrough]];
2594 case 0:
2595 default:
2596 {
2597 enemy *e = new ePatra(x,y,new_id,clk);
2598 guys.add(e);
2599 e->x = x;
2600 e->y = y;
2601 }
2602 break;
2603 }
2604
2605 break;
2606 }
2607
2608 case eeGUY:
2609 {
2610 switch(guysbuf[new_id&0xFFF].misc10)
2611 {
2612 case 1:
2613 {
2614 enemy *e = new eTrigger(x,y,new_id,clk);
2615 guys.add(e);
2616 }
2617 break;
2618
2619 case 0:
2620 default:
2621 {
2622 enemy *e = new eNPC(x,y,new_id,clk);
2623 guys.add(e);
2624 }
2625 break;
2626 }
2627
2628 break;
2629 }
2630
2631 case eeSCRIPT01:
2632 case eeSCRIPT02:
2633 case eeSCRIPT03:
2634 case eeSCRIPT04:
2635 case eeSCRIPT05:
2636 case eeSCRIPT06:
2637 case eeSCRIPT07:
2638 case eeSCRIPT08:
2639 case eeSCRIPT09:
2640 case eeSCRIPT10:
2641 case eeSCRIPT11:
2642 case eeSCRIPT12:
2643 case eeSCRIPT13:
2644 case eeSCRIPT14:
2645 case eeSCRIPT15:
2646 case eeSCRIPT16:
2647 case eeSCRIPT17:
2648 case eeSCRIPT18:
2649 case eeSCRIPT19:
2650 case eeSCRIPT20:
2651 {
2652 enemy *e = new eScript(x,y,new_id,clk);
2653 guys.add(e);
2654 e->x = x;
2655 e->y = y;
2656 break;
2657 }
2658
2659
2660 case eeFFRIENDLY01:
2661 case eeFFRIENDLY02:
2662 case eeFFRIENDLY03:
2663 case eeFFRIENDLY04:
2664 case eeFFRIENDLY05:
2665 case eeFFRIENDLY06:
2666 case eeFFRIENDLY07:
2667 case eeFFRIENDLY08:
2668 case eeFFRIENDLY09:
2669 case eeFFRIENDLY10:
2670 {
2671 enemy *e = new eFriendly(x,y,new_id,clk);
2672 guys.add(e);
2673 e->x = x;
2674 e->y = y;
2675 break;
2676 }
2677
2678
2679 default: break;
2680 }
2681
2682 // add segments of segmented enemies
2683 int32_t c=0;
2684
2685 switch(guysbuf[new_id&0xFFF].family)
2686 {
2687 case eeMOLD:
2688 {
2689 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2690 new_id &= 0xFFF;
2691
2692 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[new_id].misc1)); i++)
2693 {
2694 //christ this is messy -DD
2695 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[new_id&0xFFF].step*100))));
2696
2697 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,new_id+0x1000,segclk)))
2698 {
2699 al_trace("Moldorm segment %d could not be created!\n",i+1);
2700
2701 for(int32_t j=0; j<i+1; j++)
2702 guys.del(guys.Count()-1);
2703
2704 return 0;
2705 }
2706
2707 if(i>0)
2708 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2709
2710
2711 }
2712
2713 break;
2714 }
2715
2716 case eeLANM:
2717 {
2718 new_id &= 0xFFF;
2719 int32_t shft = guysbuf[new_id].misc2;
2720 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
2721 enemy *e = new esLanmola((zfix)x,(zfix)y,new_id+0x1000,0);
2722
2723 if(!guys.add(e))
2724 {
2725 al_trace("Lanmola segment 1 could not be created!\n");
2726 guys.del(guys.Count()-1);
2727 return 0;
2728 }
2729 e->x = x;
2730 e->y = y;
2731
2732
2733
2734 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[new_id&0xFFF].misc1)); i++)
2735 {
2736 enemy *e2 = new esLanmola((zfix)x,(zfix)y,new_id+0x2000,-(i<<shft));
2737 if(!guys.add(e2))
2738 {
2739 al_trace("Lanmola segment %d could not be created!\n",i+1);
2740
2741 for(int32_t j=0; j<i+1; j++)
2742 guys.del(guys.Count()-1);
2743
2744 return 0;
2745 }
2746 e2->x = x;
2747 e2->y = y;
2748
2749 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
2750
2751 }
2752 }
2753 break;
2754
2755 case eeMANHAN:
2756 new_id &= 0xFFF;
2757
2758 for(int32_t i=0; i<((!(guysbuf[new_id].misc2))?4:8); i++)
2759 {
2760 if(!guys.add(new esManhandla((zfix)x,(zfix)y,new_id+0x1000,i)))
2761 {
2762 al_trace("Manhandla head %d could not be created!\n",i+1);
2763
2764 for(int32_t j=0; j<i+1; j++)
2765 {
2766 guys.del(guys.Count()-1);
2767 }
2768
2769 return 0;
2770 }
2771
2772
2773 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[new_id].misc1;
2774 }
2775
2776 break;
2777
2778 case eeGLEEOK:
2779 {
2780 /*
2781 new_id &= 0xFFF;
2782 int32_t head_cnt = zc_max(1,zc_min(254,guysbuf[new_id&0xFFF].misc1));
2783 Z_scripterrlog("Gleeok head count is %d\n",head_cnt);
2784 for(int32_t i=0; i<head_cnt; i++)
2785 {
2786 //enemy *e = new esGleeok(x,y,new_id+0x1000,clk,gleeok);
2787 if(!guys.add(new esGleeok((zfix)x,(zfix)y,new_id+0x1000,c, gleeok)))
2788 {
2789 al_trace("Gleeok head %d could not be created!\n",i+1);
2790
2791 for(int32_t j=0; j<i+1; j++)
2792 {
2793 guys.del(guys.Count()-1);
2794 }
2795
2796 break;
2797 }
2798
2799 c-=guysbuf[new_id].misc4;
2800 */
2801
2802 // }
2803 }
2804 break;
2805
2806
2807 case eePATRA:
2808 {
2809 new_id &= 0xFFF;
2810 int32_t outeyes = 0;
2811 ptra = new ePatraBS((zfix)x,(zfix)y,id,clk);
2812
2813 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc1); i++)
2814 {
2815 if(!((guysbuf[new_id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,new_id+0x1000,i,ptra)):guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra))))
2816 {
2817 al_trace("Patra outer eye %d could not be created!\n",i+1);
2818
2819 for(int32_t j=0; j<i+1; j++)
2820 guys.del(guys.Count()-1);
2821
2822 return 0;
2823 }
2824 else
2825 outeyes++;
2826
2827
2828 }
2829
2830 for(int32_t i=0; i<zc_min(254,guysbuf[new_id&0xFFF].misc2); i++)
2831 {
2832 if(!guys.add(new esPatra((zfix)x,(zfix)y,new_id+0x1000,i,ptra)))
2833 {
2834 al_trace("Patra inner eye %d could not be created!\n",i+1);
2835
2836 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
2837 guys.del(guys.Count()-1);
2838
2839 return 0;
2840 }
2841
2842
2843 }
2844 delete ptra;
2845 break;
2846 }
2847 }
2848
2849
2850
2851 ((enemy*)guys.spr(guys.Count()-1))->count_enemy = true;
2852 ((enemy*)guys.spr(guys.Count()-1))->stunclk = delay_timer;
2853 ((enemy*)guys.spr(guys.Count()-1))->dir = this->dir;
2854 ((enemy*)guys.spr(guys.Count()-1))->scale = this->scale;
2855 ((enemy*)guys.spr(guys.Count()-1))->angular = this->angular;
2856 ((enemy*)guys.spr(guys.Count()-1))->angle = this->angle;
2857 ((enemy*)guys.spr(guys.Count()-1))->rotation = this->rotation;
2858 //((enemy*)guys.spr(guys.Count()-1))->mainguy = this->mainguy; //This might mean that it is a core.
2859 ((enemy*)guys.spr(guys.Count()-1))->itemguy = this->itemguy;
2860 ((enemy*)guys.spr(guys.Count()-1))->leader = this->leader;
2861 ((enemy*)guys.spr(guys.Count()-1))->hclk = delay_timer;
2862 ((enemy*)guys.spr(guys.Count()-1))->script_spawned = this->script_spawned;
2863 ((enemy*)guys.spr(guys.Count()-1))->script_UID = this->script_UID;
2864 ((enemy*)guys.spr(guys.Count()-1))->sclk = 0;
2865
2866
2867 item_set = 0; //Do not make a drop.
2868
2869 switch(effect_type)
2870 {
2871 case -7:
2872 {
2873 weapon *w = new weapon(x,y-fakez,z,wBomb,0,wdp,0,-1,getUID(),false, 0);
2874 Lwpns.add(w);
2875 break;
2876 }
2877 case -6:
2878 {
2879 weapon *w = new weapon(x,y-fakez,z,wSBomb,0,wdp,0,-1,getUID(),false, 0);
2880 Lwpns.add(w);
2881 break;
2882 }
2883 case -5:
2884 {
2885 weapon *w = new weapon(x,y-fakez,z,wBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2886 Lwpns.add(w);
2887 break;
2888 }
2889 case -4:
2890 {
2891 weapon *w = new weapon(x,y-fakez,z,wSBomb,effect_type,0,0,Hero.getUID(), txsz, tysz);
2892 Lwpns.add(w);
2893 break;
2894 }
2895 case -3: explode(1); break;
2896 case -2: explode(2); break;
2897 case -1: explode(0); break;
2898 case 0: break;
2899
2900 default:
2901 {
2902 //Dummy weapon function
2903 if ( effect_type > 255 ) effect_type = 0; //Sanity bound the sprite ID.
2904 weapon *w = new weapon(x,y-fakez,z,wSSparkle,effect_type,0,0,Hero.getUID(), txsz, tysz,0,0,0,0,0,0,0);
2905 Lwpns.add(w);
2906 break;
2907 }
2908 }
2909
2910
2911 yofs = -32768;
2912 switch(guysbuf[new_id&0xFFF].family)
2913 {
2914 case eeGLEEOK:
2915 {
2916 Z_scripterrlog("Replacing a gleeok.\n");
2917 enemy *tempenemy = (enemy *) guys.getByUID(parentCore);
2918 hp = -999;
2919 tempenemy->hp = -999;
2920 break;
2921
2922 }
2923 default:
2924 hp = -1000; break;
2925 }
2926 ++game->guys[(currmap*MAPSCRSNORMAL)+currscr];
2927 return 1;
2928
2929 }
2930 case edSPLIT:
2931 {
2932 //int32_t ex = x; int32_t ey = y;
2933 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2934 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2935 /*
2936 if ( txsx > 1 )
2937 {
2938 ex += ( txsz-1 ) * 8; //from its middle
2939 }
2940 if ( tysx > 1 )
2941 {
2942 ey += ( tysz-1 ) * 8; //from its middle
2943 }
2944 */
2945 for ( int32_t q = 0; q < dmisc4; q++ )
2946 {
2947
2948 //addenemy((x+(txsz*16)/2),(y+(tysz*16)/2),dmisc3+0x1000,-15);
2949 addenemy(
2950 //ex,ey,
2951 x,y,
2952 dmisc3+0x1000,-15);
2953 //addenemy(ex,ey,dmisc3,0);
2954
2955 }
2956 item_set = 0; //Do not make a drop.
2957 hp = -1000;
2958 return -1;
2959
2960 }
2961 case edSUMMON:
2962 {
2963
2964
2965 //al_trace("edSplit dmisc3: %d\n", dmisc3);
2966 //al_trace("edSplit dmisc4: %d\n", dmisc4);
2967 int32_t summon_count = (zc_oldrand()%dmisc4)+1;
2968 for ( int32_t q = 0; q < summon_count; q++ )
2969 {
2970 int32_t x2=16*((zc_oldrand()%12)+2);
2971 int32_t y2=16*((zc_oldrand()%7)+2);
2972 addenemy(
2973 //(x+(txsz*16)/2),(y+(tysz*16)/2)
2974 x2,y2,
2975 dmisc3+0x1000,-15);
2976 //addenemy(ex,ey,dmisc3,0);
2977
2978 }
2979 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
2980 return -1;
2981
2982 }
2983
2984 case edEXPLODESMALL:
2985 {
2986 weapon *ew=new weapon(x,y-fakez,z, ewBomb, 0, dmisc4, dir,-1,getUID(),false);
2987 Ewpns.add(ew);
2988 item_set = 0; //Should we make a drop?
2989 hp = -1000;
2990 return -1;
2991 }
2992
2993
2994 case edEXPLODEHARMLESS:
2995 {
2996 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
2997 Ewpns.add(ew);
2998 ew->hyofs = -32768;
2999 item_set = 0; //Should we make a drop?
3000 hp = -1000;
3001 return -1;
3002 }
3003
3004
3005 case edEXPLODELARGE:
3006 {
3007 weapon *ew=new weapon(x,y-fakez,z, ewSBomb, 0, dmisc4, dir,-1,getUID(),false);
3008 Ewpns.add(ew);
3009
3010 hp = -1000;
3011 return -1;
3012 }
3013
3014
3015 case edTRIGGERSECRETS:
3016 {
3017 hidden_entrance(0, true, false, -4);
3018 return -1;
3019 }
3020
3021 case edSTUNORCHINK:
3022
3/4
✓ Branch 0 taken 948 times.
✓ Branch 1 taken 841 times.
✓ Branch 2 taken 948 times.
✗ Branch 3 not taken.
3067 if (stunclk && get_qr(qr_NO_STUNLOCK))
3023 {
3024 sfx(WAV_CHINK,pan(int32_t(x)));
3025 return 1;
3026 }
3027
2/2
✓ Branch 0 taken 511 times.
✓ Branch 1 taken 1278 times.
1789 else if(*power <= 0)
3028 {
3029 //al_trace("defendNew() is at: %s\n", "returning edSTUNORCHINK");
3030 511 sfx(WAV_CHINK,pan(int32_t(x)));
3031 511 return 1;
3032 }
3033 [[fallthrough]];
3034
3035 case edSTUNORIGNORE:
3036
3/4
✓ Branch 0 taken 1438 times.
✓ Branch 1 taken 1253 times.
✓ Branch 2 taken 1438 times.
✗ Branch 3 not taken.
4578 if (stunclk && get_qr(qr_NO_STUNLOCK))
3037 {
3038 sfx(WAV_CHINK,pan(int32_t(x)));
3039 return 1;
3040 }
3041
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 1887 times.
2691 else if(*power <= 0)
3042 804 return 0;
3043 [[fallthrough]];
3044
3045 case edSTUNONLY:
3046
7/10
✓ Branch 0 taken 2789 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2789 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2789 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2733 times.
✓ Branch 7 taken 56 times.
✓ Branch 8 taken 2760 times.
✓ Branch 9 taken 29 times.
2789 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3047 {
3048 //al_trace("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3049 // Z_message("enemy::defend(), edSTUNONLY found a weapon of type FIRE, BOMB, SBOMB, HOOKSHOT, or SWORD:, with wpnId: \n", wpnId);
3050 29 return 1;
3051 }
3052
3/4
✓ Branch 0 taken 2135 times.
✓ Branch 1 taken 625 times.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
2760 if (stunclk && get_qr(qr_NO_STUNLOCK))
3053 {
3054 sfx(WAV_CHINK,pan(int32_t(x)));
3055 return 1;
3056 }
3057 else
3058 {
3059 2760 stunclk=160;
3060 2760 sfx(WAV_EHIT,pan(int32_t(x)));
3061
3062 2760 return 1;
3063 }
3064
3065 case edCHINKL1:
3066 if(*power >= 1*game->get_hero_dmgmult()) break;
3067 [[fallthrough]];
3068 case edCHINKL2:
3069
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(*power >= 2*game->get_hero_dmgmult()) break;
3070 [[fallthrough]];
3071 case edCHINKL4:
3072
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 19 times.
80 if(*power >= 4*game->get_hero_dmgmult()) break;
3073 [[fallthrough]];
3074 case edCHINKL6:
3075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 6*game->get_hero_dmgmult()) break;
3076 [[fallthrough]];
3077 case edCHINKL8:
3078
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 20 times.
35 if(*power >= 8*game->get_hero_dmgmult()) break;
3079 [[fallthrough]];
3080 case edCHINKL10:
3081
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if(*power >= 10*game->get_hero_dmgmult()) break;
3082 [[fallthrough]];
3083 case edCHINK:
3084 //al_trace("defendNew() is at: %s\n", "returning edCHINK");
3085 219 sfx(WAV_CHINK,pan(int32_t(x)));
3086 219 return 1;
3087
3088 case edIGNOREL1:
3089 if(*power > 0) break;
3090 [[fallthrough]];
3091
3092 case edIGNORE:
3093 9312 return 0;
3094
3095 case ed1HKO:
3096 322 *power = hp;
3097 322 return -2;
3098
3099 case ed2x:
3100 {
3101
1/2
✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
71 *power = zc_max(1,*power*2);
3102 //int32_t pow = *power;
3103 //*power = vbound((pow*2),0,214747);
3104 71 return -1;
3105 }
3106 case ed3x:
3107 {
3108 *power = zc_max(1,*power*3);
3109 //int32_t pow = *power;
3110 //*power = vbound((pow*3),0,214747);
3111 return -1;
3112 }
3113
3114 case ed4x:
3115 {
3116 *power = zc_max(1,*power*4);
3117 //int32_t pow = *power;
3118 //*power = vbound((pow*4),0,214747);
3119 return -1;
3120 }
3121
3122
3123 case edHEAL:
3124 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3125 //int32_t pow = *power;
3126 //*power = vbound((pow*-1),0,214747);
3127 //break;
3128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 *power = zc_min(0,*power*-1);
3129 79 return -1;
3130 }
3131 /*
3132 case edLEVELDAMAGE:
3133 {
3134 int32_t pow = *power;
3135 int32_t lvl = *level;
3136 *power = vbound((pow*lvl),0,214747);
3137 break;
3138 }
3139 case edLEVELREDUCTION:
3140 {
3141 int32_t pow = *power;
3142 int32_t lvl = *level;
3143 *power = vbound((pow/lvl),0,214747);
3144 break;
3145 }
3146 */
3147
3148 case edQUARTDAMAGE:
3149
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 1 times.
58 *power = zc_max(1,*power/2);
3150
3151 [[fallthrough]];
3152 case edHALFDAMAGE:
3153
2/2
✓ Branch 0 taken 214 times.
✓ Branch 1 taken 17 times.
231 *power = zc_max(1,*power/2);
3154 231 break;
3155
3156 case edSWITCH:
3157 {
3158 if(Hero.switchhookclk) return 0; //Already switching!
3159 switch(family)
3160 {
3161 case eeAQUA: case eeMOLD: case eeDONGO: case eeMANHAN: case eeGLEEOK:
3162 case eeDIG: case eeGHOMA: case eeLANM: case eePATRA: case eeGANON:
3163 return 0;
3164 }
3165 hooked_combopos = -1;
3166 hooked_layerbits = 0;
3167 switching_object = this;
3168 switch_hooked = true;
3169 Hero.doSwitchHook(game->get_switchhookstyle());
3170 if(QMisc.miscsfx[sfxSWITCHED])
3171 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(x));
3172 return 1;
3173 }
3174
3175 case 0:
3176 {
3177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53312 times.
53312 if(edef == edefSwitchHook)
3178 return -1;
3179
6/6
✓ Branch 0 taken 13877 times.
✓ Branch 1 taken 39435 times.
✓ Branch 2 taken 29 times.
✓ Branch 3 taken 13848 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 13 times.
53312 if (stunclk && get_qr(qr_NO_STUNLOCK) && *power == 0)
3180 {
3181 13 sfx(WAV_CHINK,pan(int32_t(x)));
3182 13 return 1;
3183 }
3184
3185 }
3186 53299 }
3187
3188 53627 return -1;
3189 72097 }
3190
3191 72097 int32_t enemy::defendNewInt(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable, weapon* w)
3192 {
3193
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 int wuid = w?w->getUID():0;
3194
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 bool fakeweap = (w && !Lwpns.getByUID(wuid));
3195
3196
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3197 Lwpns.add(w);
3198 72097 std::vector<int32_t> &ev = FFCore.eventData;
3199 72097 ev.clear();
3200 72097 ev.push_back(*power*10000);
3201 72097 ev.push_back(edef*10000);
3202 72097 ev.push_back(unblockable*10000);
3203 72097 ev.push_back(wpnId*10000);
3204 72097 ev.push_back(0);
3205 72097 ev.push_back(getUID());
3206 72097 ev.push_back(wuid);
3207
3208 72097 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT1);
3209 72097 *power = ev[0]/10000;
3210 72097 edef = ev[1]/10000;
3211 72097 unblockable = byte(ev[2]/10000);
3212 72097 wpnId = ev[3] / 10000;
3213 72097 bool nullify = ev[4]!=0;
3214 72097 ev.clear();
3215 72097 int ret = 0;
3216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 if(!nullify)
3217 {
3218 72097 ret = defendNew(wpnId, power, edef, unblockable);
3219
2/2
✓ Branch 0 taken 18999 times.
✓ Branch 1 taken 53098 times.
72097 if(ret == -1)
3220 {
3221 53098 ev.push_back(*power*10000);
3222 53098 ev.push_back(edef*10000);
3223 53098 ev.push_back(unblockable*10000);
3224 53098 ev.push_back(wpnId*10000);
3225 53098 ev.push_back(0);
3226 53098 ev.push_back(getUID());
3227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53098 times.
53098 ev.push_back(w?w->getUID():0);
3228
3229 53098 throwGenScriptEvent(GENSCR_EVENT_ENEMY_HIT2);
3230 53098 *power = ev[0]/10000;
3231 53098 nullify = ev[4]!=0;
3232 53098 ev.clear();
3233 53098 }
3234 72097 }
3235
1/2
✓ Branch 0 taken 72097 times.
✗ Branch 1 not taken.
72097 if(fakeweap)
3236 Lwpns.remove(w);
3237
3238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72097 times.
72097 return nullify ? 0 : ret;
3239 }
3240
3241 53720 int32_t enemy::defenditemclassNew(int32_t wpnId, int32_t *power, weapon *w, weapon* realweap)
3242 {
3243
2/2
✓ Branch 0 taken 53490 times.
✓ Branch 1 taken 230 times.
53720 if(!realweap) realweap = w;
3244 53720 int32_t wid = getWeaponID(w);
3245
3246 53720 int32_t edef = resolveEnemyDefence(w);
3247
2/2
✓ Branch 0 taken 1256 times.
✓ Branch 1 taken 52464 times.
53720 if(QHeader.zelda_version > 0x250)
3248 1256 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3249
2/3
✓ Branch 0 taken 993 times.
✓ Branch 1 taken 51471 times.
✗ Branch 2 not taken.
52464 switch(wid)
3250 {
3251 case wScript1: case wScript2: case wScript3: case wScript4: case wScript5:
3252 case wScript6: case wScript7: case wScript8: case wScript9: case wScript10:
3253 993 return defend(wpnId, power, edefSCRIPT);
3254
3255 case wWhistle:
3256 return -1;
3257
3258 default:
3259 51471 return defendNewInt(wid, power, edef, w->unblockable, realweap);
3260 }
3261 53720 }
3262
3263
3264 // Check defenses without actually acting on them.
3265 11966 bool enemy::candamage(int32_t power, int32_t edef, byte unblockable)
3266 {
3267
4/10
✓ Branch 0 taken 9574 times.
✓ Branch 1 taken 2059 times.
✓ Branch 2 taken 325 times.
✓ Branch 3 taken 8 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
11966 switch(defense[edef])
3268 {
3269 case edSTUNONLY:
3270 8 return false;
3271 case edSTUNORCHINK:
3272 case edCHINK:
3273 9574 return unblockable&WPNUNB_BLOCK;
3274 case edSTUNORIGNORE:
3275 case edIGNORE:
3276 2059 return unblockable&WPNUNB_IGNR;
3277
3278 case edIGNOREL1:
3279 return (unblockable&WPNUNB_IGNR) || power >= 1*game->get_hero_dmgmult();
3280 case edCHINKL1:
3281 return (unblockable&WPNUNB_BLOCK) || power >= 1*game->get_hero_dmgmult();
3282
3283 case edCHINKL2:
3284 return (unblockable&WPNUNB_BLOCK) || power >= 2*game->get_hero_dmgmult();
3285
3286 case edCHINKL4:
3287 return (unblockable&WPNUNB_BLOCK) || power >= 4*game->get_hero_dmgmult();
3288
3289 case edCHINKL6:
3290 return (unblockable&WPNUNB_BLOCK) || power >= 6*game->get_hero_dmgmult();
3291
3292 case edCHINKL8:
3293 return (unblockable&WPNUNB_BLOCK) || power >= 8*game->get_hero_dmgmult();
3294 }
3295
3296 325 return true;
3297 11966 }
3298
3299 // Do we do damage?
3300 // 0: takehit returns 0
3301 // 1: takehit returns 1
3302 // -1: do damage
3303 993 int32_t enemy::defend(int32_t wpnId, int32_t *power, int32_t edef)
3304 {
3305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 993 times.
993 if(shieldCanBlock)
3306 {
3307 switch(defense[edef])
3308 {
3309 case edIGNORE:
3310 return 0;
3311 case edIGNOREL1:
3312 case edSTUNORIGNORE:
3313 if(*power <= 0)
3314 return 0;
3315 }
3316
3317 sfx(WAV_CHINK,pan(int32_t(x)));
3318 return 1;
3319 }
3320
3321
3/22
✓ Branch 0 taken 186 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 800 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 7 times.
993 switch(defense[edef])
3322 {
3323 case edSTUNORCHINK:
3324 if(*power <= 0)
3325 {
3326 sfx(WAV_CHINK,pan(int32_t(x)));
3327 return 1;
3328 }
3329
3330 [[fallthrough]];
3331 case edSTUNORIGNORE:
3332 if(*power <= 0)
3333 return 0;
3334
3335 [[fallthrough]];
3336 case edSTUNONLY:
3337 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wHookshot || wpnId==wSword) && stunclk>=159)
3338 return 1;
3339
3340 stunclk=160;
3341 sfx(WAV_EHIT,pan(int32_t(x)));
3342 return 1;
3343
3344 case edFREEZE:
3345 frozenclock=-1;
3346 //sfx(WAV_FREEZE,pan(int32_t(x)));
3347 return 1;
3348
3349 case edCHINKL1:
3350 if(*power >= 1*game->get_hero_dmgmult()) break;
3351 [[fallthrough]];
3352 case edCHINKL2:
3353 if(*power >= 2*game->get_hero_dmgmult()) break;
3354 [[fallthrough]];
3355 case edCHINKL4:
3356 if(*power >= 4*game->get_hero_dmgmult()) break;
3357 [[fallthrough]];
3358 case edCHINKL6:
3359 if(*power >= 6*game->get_hero_dmgmult()) break;
3360 [[fallthrough]];
3361 case edCHINKL8:
3362 if(*power >= 8*game->get_hero_dmgmult()) break;
3363 [[fallthrough]];
3364 case edCHINKL10:
3365 if(*power >= 10*game->get_hero_dmgmult()) break;
3366 [[fallthrough]];
3367 case edCHINK:
3368 sfx(WAV_CHINK,pan(int32_t(x)));
3369 return 1;
3370 case edTRIGGERSECRETS:
3371 hidden_entrance(0, true, false, -4);
3372 break;
3373
3374 case edIGNOREL1:
3375 if(*power > 0) break;
3376 [[fallthrough]];
3377 case edIGNORE:
3378 800 return 0;
3379
3380 case ed1HKO:
3381 *power = hp;
3382 return -2;
3383
3384 case ed2x:
3385 {
3386 *power = zc_max(1,*power*2);
3387 //int32_t pow = *power;
3388 //*power = vbound((pow*2),0,214747);
3389 return -1;
3390 }
3391 case ed3x:
3392 {
3393 *power = zc_max(1,*power*3);
3394 //int32_t pow = *power;
3395 //*power = vbound((pow*3),0,214747);
3396 return -1;
3397 }
3398
3399 case ed4x:
3400 {
3401 *power = zc_max(1,*power*4);
3402 //int32_t pow = *power;
3403 //*power = vbound((pow*4),0,214747);
3404 return -1;
3405 }
3406
3407
3408 case edHEAL:
3409 { //Probably needs its own function, or routine in the damage functuon to heal if power is negative.
3410 //int32_t pow = *power;
3411 //*power = vbound((pow*-1),0,214747);
3412 //break;
3413 *power = zc_min(0,*power*-1);
3414 return -1;
3415 }
3416 /*
3417 case edLEVELDAMAGE:
3418 {
3419 int32_t pow = *power;
3420 int32_t lvl = *level;
3421 *power = vbound((pow*lvl),0,214747);
3422 break;
3423 }
3424 case edLEVELREDUCTION:
3425 {
3426 int32_t pow = *power;
3427 int32_t lvl = *level;
3428 *power = vbound((pow/lvl),0,214747);
3429 break;
3430 }
3431 */
3432
3433
3434 case edQUARTDAMAGE:
3435
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3436
3437 [[fallthrough]];
3438 case edHALFDAMAGE:
3439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 *power = zc_max(1,*power/2);
3440 7 break;
3441 }
3442
3443 193 return -1;
3444 993 }
3445
3446 // Defend against a particular item class.
3447 int32_t enemy::defenditemclass(int32_t wpnId, int32_t *power)
3448 {
3449 int32_t def=-1;
3450
3451 switch(wpnId)
3452 {
3453 // These first 2 are only used by Gohma... enemy::takehit() has complicated stun-calculation code for these.
3454 case wBrang:
3455 def = defend(wpnId, power, edefBRANG);
3456 break;
3457
3458 case wHookshot:
3459 def = defend(wpnId, power, edefHOOKSHOT);
3460 break;
3461
3462 // Anyway...
3463 case wBomb:
3464 def = defend(wpnId, power, edefBOMB);
3465 break;
3466
3467 case wSBomb:
3468 def = defend(wpnId, power, edefSBOMB);
3469 break;
3470
3471 case wArrow:
3472 def = defend(wpnId, power, edefARROW);
3473 break;
3474
3475 case wFire:
3476 def = defend(wpnId, power, edefFIRE);
3477 break;
3478
3479 case wWand:
3480 def = defend(wpnId, power, edefWAND);
3481 break;
3482
3483 case wMagic:
3484 def = defend(wpnId, power, edefMAGIC);
3485 break;
3486
3487 case wHammer:
3488 def = defend(wpnId, power, edefHAMMER);
3489 break;
3490
3491 case wSword:
3492 def = defend(wpnId, power, edefSWORD);
3493 break;
3494
3495 case wBeam:
3496 def = defend(wpnId, power, edefBEAM);
3497 break;
3498
3499 case wRefBeam:
3500 def = defend(wpnId, power, edefREFBEAM);
3501 break;
3502
3503 case wRefMagic:
3504 def = defend(wpnId, power, edefREFMAGIC);
3505 break;
3506
3507 case wRefFireball:
3508 def = defend(wpnId, power, edefREFBALL);
3509 break;
3510
3511 case wRefRock:
3512 def = defend(wpnId, power, edefREFROCK);
3513 break;
3514
3515 case wStomp:
3516 def = defend(wpnId, power, edefSTOMP);
3517 break;
3518
3519 case wCByrna:
3520 def = defend(wpnId, power, edefBYRNA);
3521 break;
3522
3523 case wScript1:
3524 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT01);
3525 else def = defend(wpnId, power, edefSCRIPT);
3526 break;
3527
3528 case wScript2:
3529 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT02);
3530 else def = defend(wpnId, power, edefSCRIPT);
3531 break;
3532
3533 case wScript3:
3534 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT03);
3535 else def = defend(wpnId, power, edefSCRIPT);
3536 break;
3537
3538 case wScript4:
3539 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT04);
3540 else def = defend(wpnId, power, edefSCRIPT);
3541 break;
3542
3543 case wScript5:
3544 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT05);
3545 else def = defend(wpnId, power, edefSCRIPT);
3546 break;
3547
3548 case wScript6:
3549 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT06);
3550 else def = defend(wpnId, power, edefSCRIPT);
3551 break;
3552
3553 case wScript7:
3554 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT07);
3555 else def = defend(wpnId, power, edefSCRIPT);
3556 break;
3557
3558 case wScript8:
3559 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT08);
3560 else def = defend(wpnId, power, edefSCRIPT);
3561 break;
3562
3563 case wScript9:
3564 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT09);
3565 else def = defend(wpnId, power, edefSCRIPT);
3566 break;
3567
3568 case wScript10:
3569 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefSCRIPT10);
3570 else def = defend(wpnId, power, edefSCRIPT);
3571 break;
3572
3573 case wWhistle:
3574 if(QHeader.zelda_version > 0x250) def = defend(wpnId, power, edefWhistle);
3575 else break;
3576 break;
3577
3578
3579 //!ZoriaRPG : We need some special cases here, to ensure that old script defs don;t break.
3580 //Probably best to do this from the qest file, loading the values of Script(generic) into each
3581 //of the ten if the quest version is lower than N.
3582 //Either that, or we need a boolean flag to set int32_t he enemy editor, or by ZScript that changes this behaviour.
3583 //such as bool UseSeparatedScriptDefences. hah.
3584 default:
3585 //if(wpnId>=wScript1 && wpnId<=wScript10)
3586 // {
3587 // def = defend(wpnId, power, edefSCRIPT);
3588 // }
3589 // }
3590
3591 break;
3592 }
3593
3594 return def;
3595 }
3596
3597 // take damage or ignore it
3598 // -1: damage (if any) dealt
3599 // 1: blocked
3600 // 0: weapon passes through unhindered
3601 159739 int32_t enemy::takehit(weapon *w, weapon* realweap)
3602 {
3603
2/4
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 159739 times.
159739 if(fallclk||drownclk) return 0;
3604
2/2
✓ Branch 0 taken 34416 times.
✓ Branch 1 taken 125323 times.
159739 if(!realweap) realweap = w;
3605 159739 int32_t wpnId = w->id;
3606 159739 int32_t power = w->power;
3607 159739 int32_t wpnx = w->x;
3608 159739 int32_t wpny = w->y;
3609 159739 int32_t enemyHitWeapon = w->parentitem;
3610 int32_t wpnDir;
3611 159739 int32_t parent_item = w->parentitem;
3612
3613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159739 times.
159739 if ( w->useweapon > 0 /*&& wpnId != wWhistle*/ )
3614 {
3615 wpnId = w->useweapon;
3616 }
3617
3618 // If it's a boomerang that just bounced, use the opposite direction;
3619 // otherwise, it might bypass a shield. This probably won't handle
3620 // every case correctly, but it's better than having shields simply
3621 // not work against boomerangs.
3622
8/8
✓ Branch 0 taken 18979 times.
✓ Branch 1 taken 140760 times.
✓ Branch 2 taken 11895 times.
✓ Branch 3 taken 7084 times.
✓ Branch 4 taken 11291 times.
✓ Branch 5 taken 604 times.
✓ Branch 6 taken 2653 times.
✓ Branch 7 taken 8638 times.
159739 if(w->id==wBrang && w->misc==1 && w->clk2>=256 && w->clk2<264)
3623 8638 wpnDir = oppositeDir[w->dir];
3624 else
3625 151101 wpnDir = w->dir;
3626
3627
5/8
✓ Branch 0 taken 159739 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159739 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159739 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 761 times.
✓ Branch 7 taken 160110 times.
159739 if(dying || clk<0 || hclk>0 || superman)
3628 761 return 0;
3629
3630 //Prevent boomerang from writing to hitby[] for more than one frame.
3631 //This also prevents stunlock.
3632 //if ( stunclk > 0 ) return 0;
3633 //this needs a rule for boomerangs that cannot stunlock!
3634 //further, bouncing weapons should probably SFX_CHINK and bounce here.
3635 //sigh.
3636
3637 160110 int32_t ret = -1;
3638
3639 // This obscure quest rule...
3640
5/6
✓ Branch 0 taken 77360 times.
✓ Branch 1 taken 82750 times.
✓ Branch 2 taken 77192 times.
✓ Branch 3 taken 168 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 77192 times.
160110 if(get_qr(qr_BOMBDARKNUTFIX) && (wpnId==wBomb || wpnId==wSBomb))
3641 {
3642 double _MSVC2022_tmp1, _MSVC2022_tmp2;
3643 168 double ddir=atan2_MSVC2022_FIX(double(wpny-y),double(x-wpnx));
3644 168 wpnDir=zc_oldrand()&3;
3645
3646
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 85 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
168 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
3647 {
3648 59 wpnDir=down;
3649 59 }
3650
4/4
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 29 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 56 times.
109 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
3651 {
3652 56 wpnDir=right;
3653 56 }
3654
4/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 14 times.
53 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
3655 {
3656 14 wpnDir=up;
3657 14 }
3658 else
3659 {
3660 39 wpnDir=left;
3661 }
3662 168 }
3663
3664 160110 int32_t xdir = dir;
3665 160110 shieldCanBlock=false;
3666
3667 //if (family==eeFLOAT && flags&(inv_front|inv_back_inv_left|inv_right)) xdir=down;
3668
4/4
✓ Branch 0 taken 158266 times.
✓ Branch 1 taken 1844 times.
✓ Branch 2 taken 406 times.
✓ Branch 3 taken 157860 times.
160905 if(!(w->unblockable&WPNUNB_BLOCK)&&((wpnId==wHookshot && hitshield(wpnx, wpny, xdir))
3669
10/10
✓ Branch 0 taken 13418 times.
✓ Branch 1 taken 13012 times.
✓ Branch 2 taken 18111 times.
✓ Branch 3 taken 152761 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 152703 times.
✓ Branch 6 taken 984 times.
✓ Branch 7 taken 151719 times.
✓ Branch 8 taken 795 times.
✓ Branch 9 taken 150924 times.
158266 || ((flags&inv_front && wpnDir==(xdir^down)) || (flags&inv_back && wpnDir==(xdir^up)) || (flags&inv_left && wpnDir==(xdir^left)) || (flags&inv_right && wpnDir==(xdir^right))))
3670 )
3671 // The hammer should already be dealt with by subclasses (Walker etc.)
3672 {
3673
9/9
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 263 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 3758 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 4 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 1317 times.
✓ Branch 8 taken 484 times.
33366 switch(wpnId)
3674 {
3675 // Weapons which shields protect against
3676 case wSword:
3677 case wWand:
3678
1/2
✓ Branch 0 taken 3758 times.
✗ Branch 1 not taken.
3758 if(Hero.getCharging()>0)
3679 Hero.setAttackClk(Hero.getAttackClk()+1); //Cancel charging
3680
3681 [[fallthrough]];
3682 case wHookshot:
3683 case wHSHandle:
3684 case wBrang:
3685 4021 shieldCanBlock=true;
3686 4273 break;
3687
3688 case wBeam:
3689 case wRefBeam:
3690 // Mirror shielded enemies!
3691 #if 0
3692 if(false /*flags2&guy_mirror*/ && !get_qr(qr_SWORDMIRROR))
3693 {
3694 if(wpnId>wEnemyWeapons)
3695 return 0;
3696
3697 sfx(WAV_CHINK,pan(int32_t(x)));
3698 return 1;
3699 }
3700
3701 #endif
3702
3703 [[fallthrough]];
3704 case wRefRock:
3705 case wRefFireball:
3706 case wMagic:
3707 #if 0
3708 if(false /*flags2&guy_mirror*/ && (wpnId!=wRefRock || get_qr(qr_REFLECTROCKS)))
3709 {
3710 sfx(WAV_CHINK,pan(int32_t(x)));
3711 return 3;
3712 }
3713
3714 #endif
3715
3716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(wpnId>wEnemyWeapons)
3717 return 0;
3718
3719 [[fallthrough]];
3720 default:
3721 1597 shieldCanBlock=true;
3722 1597 break;
3723
3724 // Bombs
3725 case wSBomb:
3726 case wBomb:
3727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (!get_qr(qr_TRUEFIXEDBOMBSHIELD)) goto hitclock;
3728 else if (!get_qr(qr_BOMBSPIERCESHIELD))
3729 {
3730 sfx(WAV_CHINK,pan(int32_t(x)));
3731 return 0;
3732 }
3733 else break;
3734
3735 // Weapons which ignore shields
3736 case wWhistle:
3737 case wHammer:
3738 1 break;
3739
3740 // Weapons which shouldn't be removed by shields
3741 case wLitBomb:
3742 case wLitSBomb:
3743 case wWind:
3744 case wPhantom:
3745 case wSSparkle:
3746 case wBait:
3747 423 return 0;
3748
3749 case wFire:
3750 ;
3751 484 }
3752 6103 }
3753
3754
7/8
✓ Branch 0 taken 72714 times.
✓ Branch 1 taken 53047 times.
✓ Branch 2 taken 211 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11966 times.
✓ Branch 5 taken 18964 times.
✓ Branch 6 taken 406 times.
✓ Branch 7 taken 1563 times.
158871 switch(wpnId)
3755 {
3756 case wWhistle: //No longer completely ignore whistle weapons! -Z
3757 {
3758
3759
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 211 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
211 if ( ((itemsbuf[parent_item].flags & ITEM_FLAG2) == 0) || ( parent_item == -1 ) ) //if the flag is set, or the weapon is scripted
3760 {
3761 //al_trace("Whistle weapon in %s\n", "takehit flag == 0");
3762 211 return 0; break;
3763 }
3764 else
3765 {
3766 w->power = power = itemsbuf[parent_item].misc5;
3767
3768 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3769
3770 if(def <= 0)
3771 {
3772 if ( def == -2 ) hp -= hp;
3773 else hp -= power;
3774 return def;
3775 }
3776 break;
3777 }
3778 break;
3779 }
3780
3781 case wPhantom:
3782 return 0;
3783
3784 case wLitBomb:
3785 case wLitSBomb:
3786 case wBait:
3787 case wWind:
3788 case wSSparkle:
3789 72714 return 0;
3790
3791 case wFSparkle:
3792
3793 // Only take sparkle damage if the sparkle's parent item is not
3794 // defended against.
3795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11966 times.
11966 if(enemyHitWeapon > -1)
3796 {
3797 11966 int32_t p = 0;
3798 11966 int32_t f = itemsbuf[enemyHitWeapon].family;
3799
3800
1/4
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11966 times.
11966 switch(f)
3801 {
3802 case itype_arrow:
3803 if(!candamage(p, edefARROW, w->unblockable)) return 0;
3804
3805 break;
3806
3807 case itype_cbyrna:
3808 if(!candamage(p, edefBYRNA, w->unblockable)) return 0;
3809
3810 break;
3811
3812 case itype_brang:
3813
2/2
✓ Branch 0 taken 325 times.
✓ Branch 1 taken 11641 times.
11966 if(!candamage(p, edefBRANG, w->unblockable)) return 0;
3814
3815 325 break;
3816
3817 default:
3818 return 0;
3819 }
3820 325 }
3821
3822 325 wpnId = wSword;
3823 325 power = game->get_hero_dmgmult()>>1;
3824 325 goto fsparkle;
3825 break;
3826
3827 case wBrang:
3828 {
3829 //int32_t def = defendNew(wpnId, &power, edefBRANG, w);
3830 18964 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3831 //preventing stunlock might be best, here. -Z
3832
2/2
✓ Branch 0 taken 4250 times.
✓ Branch 1 taken 14714 times.
18964 if(def >= 0) return def;
3833
3834 // Not hurt by 0-damage weapons
3835
2/2
✓ Branch 0 taken 2271 times.
✓ Branch 1 taken 12443 times.
14714 if(!(flags & guy_bhit))
3836 {
3837 12443 stunclk=160;
3838
3839
3/4
✓ Branch 0 taken 12443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1200 times.
✓ Branch 3 taken 11243 times.
12443 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))
3840 {
3841
1/2
✓ Branch 0 taken 1200 times.
✗ Branch 1 not taken.
1200 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))*game->get_hero_dmgmult();
3842 1200 goto hitclock;
3843 }
3844
3845 11243 break;
3846 }
3847
3848
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 1887 times.
2271 if(!power)
3849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1887 times.
1887 hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_brang))*game->get_hero_dmgmult();
3850 else
3851 384 hp-=power;
3852
3853 2271 goto hitclock;
3854 }
3855
3856 case wHookshot:
3857 {
3858 //int32_t def = defendNew(wpnId, &power, edefHOOKSHOT,w);
3859 406 int32_t def = defendNewInt(wpnId, &power, resolveEnemyDefence(w), w->unblockable, realweap);
3860
3861
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 221 times.
406 if(def >= 0) return def;
3862
3863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221 times.
221 bool swgrab = switch_hooked || w->family_class == itype_switchhook;
3864
3/4
✓ Branch 0 taken 221 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 215 times.
✓ Branch 3 taken 6 times.
221 if(swgrab || !(flags & guy_bhit))
3865 {
3866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 215 times.
215 if(!swgrab)
3867 215 stunclk=160;
3868
3869
2/4
✓ Branch 0 taken 215 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 215 times.
215 if(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))
3870 {
3871 hp -= (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot))*game->get_hero_dmgmult();
3872 goto hitclock;
3873 }
3874
3875 215 break;
3876 }
3877
3878
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!power) hp-=(enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].fam_type : current_item(itype_hookshot))*game->get_hero_dmgmult();
3879 else
3880 hp-=power;
3881
3882 6 goto hitclock;
3883 }
3884 break;
3885
3886 case wHSHandle:
3887 {
3888
3/4
✓ Branch 0 taken 1563 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✓ Branch 3 taken 1484 times.
1563 if(itemsbuf[enemyHitWeapon>-1 ? enemyHitWeapon : current_item_id(itype_hookshot)].flags & ITEM_FLAG1)
3889 79 return 0;
3890
3891
3/4
✓ Branch 0 taken 1093 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 391 times.
✗ Branch 3 not taken.
1484 bool ignorehookshot = ((defense[edefHOOKSHOT] == edIGNORE) || ((defense[edefHOOKSHOT] == edIGNOREL1 || defense[edefHOOKSHOT] == edSTUNORIGNORE)
3892
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 391 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
391 && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_hookshot)) <= 0));
3893
3894 // Peahats, Darknuts, Aquamentuses, Pols Voices, Wizzrobes, Manhandlas
3895
6/8
✓ Branch 0 taken 452 times.
✓ Branch 1 taken 1032 times.
✓ Branch 2 taken 452 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 452 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 370 times.
1801 if(!(family==eePEAHAT || family==eeAQUA || family==eeMANHAN || (family==eeWIZZ && !ignorehookshot)
3896
6/6
✓ Branch 0 taken 598 times.
✓ Branch 1 taken 516 times.
✓ Branch 2 taken 317 times.
✓ Branch 3 taken 651 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 334 times.
452 || (family==eeWALK && dmisc9==e9tPOLSVOICE) || (family==eeWALK && flags&(inv_back|inv_front|inv_left|inv_right))))
3897 334 return 0;
3898
3899 2182 power = game->get_hero_dmgmult();
3900 2507 }
3901
3902 fsparkle:
3903
3904 [[fallthrough]];
3905 default:
3906 // Work out the defenses!
3907 {
3908 53490 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
3909
3910
2/2
✓ Branch 0 taken 14920 times.
✓ Branch 1 taken 38570 times.
53490 if(def >= 0)
3911 14920 return def;
3912
2/2
✓ Branch 0 taken 38280 times.
✓ Branch 1 taken 290 times.
38570 else if(def == -2)
3913 {
3914 290 ret = 0;
3915 290 }
3916 }
3917
3918
2/2
✓ Branch 0 taken 38568 times.
✓ Branch 1 taken 2 times.
77140 if(!power)
3919 {
3920
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(flags & guy_bhit)
3921 2 hp-=1;
3922 else
3923 {
3924 // Don't make a long chain of 'stun' hits
3925 if((wpnId==wFire || wpnId==wBomb || wpnId==wSBomb || wpnId==wSword) && stunclk>0)
3926 return 1;
3927
3928
3929 if(!switch_hooked)
3930 stunclk=160;
3931 break;
3932 }
3933 2 }
3934 38568 else hp-=power;
3935
3936 hitclock:
3937 42051 hclk=33;
3938
3939 // Use w->dir instead of wpnDir to make sure boomerangs don't push enemies the wrong way
3940
2/2
✓ Branch 0 taken 19451 times.
✓ Branch 1 taken 22600 times.
42051 if((dir&2)==(w->dir&2))
3941 {
3942 22600 sclk=(w->dir<<8)+16;
3943 22600 }
3944 42051 }
3945
3946
5/6
✓ Branch 0 taken 38795 times.
✓ Branch 1 taken 14714 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 46788 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6721 times.
53509 if(((wpnId==wBrang) || (get_qr(qr_NOFLASHDEATH))) && (hp<=0 && !immortal))
3947 {
3948 6721 fading=fade_blue_poof;
3949 6721 }
3950
3951
6/6
✓ Branch 0 taken 52505 times.
✓ Branch 1 taken 1004 times.
✓ Branch 2 taken 34805 times.
✓ Branch 3 taken 17700 times.
✓ Branch 4 taken 1927 times.
✓ Branch 5 taken 32878 times.
53509 if ( FFCore.getQuestHeaderInfo(vZelda) > 0x250 || ( FFCore.getQuestHeaderInfo(vZelda) == 0x250 && FFCore.getQuestHeaderInfo(vBuild) > 31 )) //2.53 Gamma 2 and later
3952 {
3953
1/2
✓ Branch 0 taken 2931 times.
✗ Branch 1 not taken.
2931 if( hitsfx > 0 ) //user-set hit sound.
3954 {
3955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2931 times.
2931 if (!dying) //don't play the hit sound on death! -Z
3956 2931 sfx(hitsfx, pan(int32_t(x)));
3957 2931 }
3958 else sfx(WAV_EHIT, pan(int32_t(x))); //Don't play the hardcoded sound if the user sets a custom one.
3959 2931 }
3960 else //2.50.2 or earlier
3961 {
3962 50578 sfx(WAV_EHIT, pan(int32_t(x)));
3963 50578 sfx(hitsfx, pan(int32_t(x)));
3964 }
3965
2/2
✓ Branch 0 taken 53499 times.
✓ Branch 1 taken 10 times.
53509 if(family==eeGUY)
3966 10 sfx(WAV_EDEAD, pan(int32_t(x)));
3967
3968 // Penetrating weapons
3969
4/4
✓ Branch 0 taken 52712 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 47718 times.
✓ Branch 3 taken 5791 times.
53509 if((wpnId==wArrow || wpnId==wBeam) && !cannotpenetrate())
3970 {
3971 5791 int32_t item=enemyHitWeapon;
3972
3973
2/2
✓ Branch 0 taken 642 times.
✓ Branch 1 taken 5149 times.
5791 if(wpnId==wArrow)
3974 {
3975 //If we use an arrow type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3976
5/6
✓ Branch 0 taken 527 times.
✓ Branch 1 taken 115 times.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 457 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 70 times.
642 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG1) && (itemsbuf[parent_item].family == itype_arrow))
3977 70 return 0;
3978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 572 times.
572 else if(get_qr(qr_ARROWS_ALWAYS_PENETRATE)) return 0;
3979 //if(item<0)
3980 else
3981 572 item=current_item_id(itype_arrow);
3982 572 }
3983
3984 else
3985 {
3986
3987 //If we use an swordbeam type for the item's Weapon type, the flags differ, so we need to rely on the flags from an arrow class.
3988
3/6
✓ Branch 0 taken 5131 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5131 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
5149 if(item>=0 && (itemsbuf[item].flags&ITEM_FLAG3) && (itemsbuf[parent_item].family == itype_sword))
3989 return 0;
3990
3991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5149 times.
5149 else if(get_qr(qr_SWORDBEAMS_ALWAYS_PENETRATE)) return 0;
3992 else
3993 //if(item<0)
3994 5149 item=current_item_id(itype_sword);
3995 }
3996 5721 }
3997
3998 53439 return ret;
3999 159027 }
4000
4001 29337462 bool enemy::dont_draw()
4002 {
4003
6/6
✓ Branch 0 taken 29226987 times.
✓ Branch 1 taken 110475 times.
✓ Branch 2 taken 29156080 times.
✓ Branch 3 taken 70907 times.
✓ Branch 4 taken 34083 times.
✓ Branch 5 taken 29192904 times.
29337462 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4004 144558 return true;
4005
4006
2/2
✓ Branch 0 taken 286146 times.
✓ Branch 1 taken 28906758 times.
29192904 if(flags&guy_invisible)
4007 286146 return true;
4008
4009
3/4
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 28906326 times.
✓ Branch 2 taken 432 times.
✗ Branch 3 not taken.
28906758 if(flags&lens_only && !lensclk)
4010 return true;
4011
4012
3/8
✓ Branch 0 taken 45951 times.
✓ Branch 1 taken 28860807 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 45951 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
28906758 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) &&
4013 !((flags&lens_only) && (get_qr(qr_LENSSEESENEMIES) || (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5))))
4014 return true;
4015
4016 28906758 return false;
4017 29337462 }
4018
4019 #define DRAW_NORMAL 2
4020 #define DRAW_CLOAKED 1
4021 #define DRAW_INVIS 0
4022 // base drawing function to be used by all derived classes instead of
4023 // sprite::draw()
4024 24870233 void enemy::draw(BITMAP *dest)
4025 {
4026 24870233 didScriptThisFrame = false; //Since there's no better place to put it
4027
6/6
✓ Branch 0 taken 24512538 times.
✓ Branch 1 taken 357695 times.
✓ Branch 2 taken 24429888 times.
✓ Branch 3 taken 82650 times.
✓ Branch 4 taken 153900 times.
✓ Branch 5 taken 24358638 times.
24870233 if(fading==fade_invisible || (((flags2&guy_blinking)||(fading==fade_flicker)) && (clk&1)))
4028 511595 return;
4029
2/2
✓ Branch 0 taken 1573842 times.
✓ Branch 1 taken 22784796 times.
24358638 if(flags&guy_invisible)
4030 1573842 return;
4031
3/8
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26258 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
22784796 if(lensclk && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) && !(flags&lens_only))
4032 return;
4033
4034 //We did the normal don't_draw stuff here so we can make exceptions; specifically the lens check (which should make enemies
4035 // be cloaked if they have "invisible displays as cloaked" checked.
4036
4037 22784796 byte canSee = DRAW_NORMAL;
4038 //Enemy specific stuff
4039
1/2
✓ Branch 0 taken 22784796 times.
✗ Branch 1 not taken.
22784796 if ( editorflags & ENEMY_FLAG1 )
4040 {
4041 canSee = DRAW_INVIS;
4042 if (editorflags & ENEMY_FLAG4) canSee = DRAW_CLOAKED;
4043 if (dmisc13 >= 0 && (editorflags & ENEMY_FLAG2))
4044 {
4045 if (game->item[dmisc13])
4046 {
4047 canSee = DRAW_NORMAL;
4048 }
4049 //else if ( lensclk && getlensid.flags SHOWINVIS )
4050 //{
4051 //
4052 //}
4053 //else
4054 //{
4055 // if ( (editorflags & ENEMY_FLAG4) ) canSee = DRAW_CLOAKED;
4056 // //otherwisem invisible
4057 //}
4058 }
4059 }
4060 //Room specific
4061
2/2
✓ Branch 0 taken 22592772 times.
✓ Branch 1 taken 192024 times.
22784796 if (tmpscr->flags3&fINVISROOM)
4062 {
4063
4/6
✓ Branch 0 taken 192024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33839 times.
✓ Branch 3 taken 158185 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33839 times.
225863 if (canSee == DRAW_NORMAL && !(current_item(itype_amulet)) &&
4064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33839 times.
33839 !((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG5) && lensclk) && family!=eeGANON) canSee = DRAW_CLOAKED;
4065 192024 }
4066 //Lens check
4067
2/2
✓ Branch 0 taken 26258 times.
✓ Branch 1 taken 22758538 times.
22784796 if (lensclk)
4068 {
4069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26258 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26258 if((itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG6) && !(flags&lens_only))
4070 {
4071 if (canSee == DRAW_NORMAL)
4072 {
4073 if (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG7) canSee = DRAW_CLOAKED;
4074 else canSee = DRAW_INVIS; //Should never happen cause dont_draw should catch this, but just in case.
4075 }
4076 }
4077
2/2
✓ Branch 0 taken 25826 times.
✓ Branch 1 taken 432 times.
26258 if(flags&lens_only)
4078 {
4079
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 432 times.
432 if (canSee == DRAW_INVIS) canSee = DRAW_NORMAL;
4080 432 }
4081 26258 }
4082 else
4083 {
4084
2/2
✓ Branch 0 taken 22685122 times.
✓ Branch 1 taken 73416 times.
22758538 if(flags&lens_only)
4085 73416 canSee = DRAW_INVIS;
4086 }
4087
3/4
✓ Branch 0 taken 73416 times.
✓ Branch 1 taken 22711380 times.
✓ Branch 2 taken 73416 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_INVIS && (editorflags & ENEMY_FLAG4)) canSee = DRAW_CLOAKED;
4088
3/4
✓ Branch 0 taken 22677541 times.
✓ Branch 1 taken 107255 times.
✓ Branch 2 taken 22677541 times.
✗ Branch 3 not taken.
22784796 if (canSee == DRAW_NORMAL && (editorflags & ENEMY_FLAG16)) canSee = DRAW_CLOAKED;
4089
4090
2/2
✓ Branch 0 taken 22711380 times.
✓ Branch 1 taken 73416 times.
22784796 if (canSee == DRAW_INVIS)
4091 73416 return;
4092
4093
3/4
✓ Branch 0 taken 22711238 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22711238 times.
22711380 if(fallclk||drownclk)
4094 {
4095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if (canSee == DRAW_CLOAKED)
4096 {
4097 sprite::drawcloaked(dest);
4098 }
4099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 else if (canSee == DRAW_NORMAL)
4100 {
4101 142 sprite::draw(dest);
4102 142 }
4103 142 return;
4104 }
4105 22711238 int32_t cshold=cs;
4106
4107
2/2
✓ Branch 0 taken 531444 times.
✓ Branch 1 taken 22179794 times.
22711238 if(dying)
4108 {
4109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if(clk2>=19)
4110 {
4111 if(!(clk2&2))
4112 {
4113 //if the enemy isn't totally invisible, or if it is, but Hero has the item needed to reveal it, draw it.
4114 if (canSee == DRAW_CLOAKED)
4115 {
4116 sprite::drawcloaked(dest);
4117 }
4118 else if (canSee == DRAW_NORMAL)
4119 {
4120 sprite::draw(dest);
4121 }
4122 }
4123 return;
4124 }
4125
4126 531444 flip = 0;
4127 531444 tile = wpnsbuf[spr_death].tile;
4128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 531444 times.
531444 if ( do_animation )
4129 {
4130 531444 int32_t offs = 0;
4131
2/2
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4132 {
4133
2/2
✓ Branch 0 taken 4568 times.
✓ Branch 1 taken 239 times.
4807 if(clk2 > 2)
4134 {
4135 239 spr_death_anim_clk=0;
4136 239 clk2=1;
4137
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 235 times.
239 if(hp > -1000)
4138 235 death_sfx();
4139 239 }
4140
4/4
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 335 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4456 times.
4807 if(clk2==1 && spr_death_anim_clk>-1)
4141 {
4142 4456 ++clk2;
4143
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
4456 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4144
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 4437 times.
4456 spr_death_anim_frm *= zc_max(1,txsz);
4145 4456 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4146
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 4382 times.
4456 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4147
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4456 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4456 times.
✓ Branch 4 taken 4217 times.
✓ Branch 5 taken 239 times.
4456 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4148 {
4149 239 spr_death_anim_clk=-1;
4150 239 clk2=1;
4151 239 }
4152 4456 }
4153 4807 tile += spr_death_anim_frm;
4154 4807 }
4155
2/2
✓ Branch 0 taken 79136 times.
✓ Branch 1 taken 447501 times.
526637 else if(BSZ)
4156 {
4157
2/2
✓ Branch 0 taken 62225 times.
✓ Branch 1 taken 16911 times.
79136 offs = zc_min((15-clk2)/3,4);
4158 79136 }
4159
4/4
✓ Branch 0 taken 298376 times.
✓ Branch 1 taken 149125 times.
✓ Branch 2 taken 149027 times.
✓ Branch 3 taken 149349 times.
447501 else if(clk2>6 && clk2<=12)
4160 {
4161 149349 offs = 1;
4162 149349 }
4163
4164
2/2
✓ Branch 0 taken 314434 times.
✓ Branch 1 taken 217010 times.
531444 if(offs)
4165 {
4166
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs *= zc_max(1,txsz);
4167 217010 int32_t rows = TILEROW(tile+offs)-TILEROW(tile);
4168
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 216866 times.
217010 offs += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4169 217010 }
4170 531444 tile += offs;
4171 531444 }
4172
4173
6/6
✓ Branch 0 taken 526637 times.
✓ Branch 1 taken 4807 times.
✓ Branch 2 taken 447501 times.
✓ Branch 3 taken 79136 times.
✓ Branch 4 taken 129054 times.
✓ Branch 5 taken 318447 times.
531444 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4174 212997 cs = wpnsbuf[spr_death].csets&15;
4175 else
4176 318447 cs = (((clk2+5)>>1)&3)+6;
4177 531444 }
4178
3/4
✓ Branch 0 taken 662995 times.
✓ Branch 1 taken 21516799 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662995 times.
22179794 else if(hclk>0 && getCanFlicker())
4179 {
4180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 662995 times.
662995 if(family==eeGANON)
4181 cs=(((hclk-1)>>1)&3)+6;
4182
4/4
✓ Branch 0 taken 613464 times.
✓ Branch 1 taken 49531 times.
✓ Branch 2 taken 174016 times.
✓ Branch 3 taken 439448 times.
662995 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4183 439448 cs=(((hclk-1)>>1)&3)+6;
4184 662995 }
4185 //draw every other frame for flickering enemies
4186
8/10
✓ Branch 0 taken 11349962 times.
✓ Branch 1 taken 11361276 times.
✓ Branch 2 taken 11349962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 567307 times.
✓ Branch 5 taken 10782655 times.
✓ Branch 6 taken 137002 times.
✓ Branch 7 taken 430305 times.
✓ Branch 8 taken 137002 times.
✗ Branch 9 not taken.
22711238 if((frame&1)==1 || !(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER) && getCanFlicker()))
4187 {
4188
2/2
✓ Branch 0 taken 33668 times.
✓ Branch 1 taken 22540568 times.
22574236 if (canSee == DRAW_CLOAKED)
4189 {
4190 33668 sprite::drawcloaked(dest);
4191 33668 }
4192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22540568 times.
22540568 else if (canSee == DRAW_NORMAL)
4193 {
4194
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22540568 times.
22540568 if ( frozenclock < 0 )
4195 {
4196 if ( frozentile > 0 ) tile = frozentile;
4197 loadpalset(csBOSS,frozencset);
4198 }
4199 22540568 sprite::draw(dest);
4200 22540568 }
4201 22574236 }
4202 22711238 cs=cshold;
4203 24870233 }
4204
4205 //old zc bosses
4206 23264120 void enemy::drawzcboss(BITMAP *dest)
4207 {
4208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23264120 times.
23264120 if(dont_draw())
4209 return;
4210
4211 23264120 int32_t cshold=cs;
4212
4213
2/2
✓ Branch 0 taken 492438 times.
✓ Branch 1 taken 22771682 times.
23264120 if(dying)
4214 {
4215
2/2
✓ Branch 0 taken 2592 times.
✓ Branch 1 taken 489846 times.
492438 if(clk2>=19)
4216 {
4217
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 1296 times.
2592 if(!(clk2&2))
4218 1296 sprite::drawzcboss(dest);
4219
4220 2592 return;
4221 }
4222
4223 489846 flip = 0;
4224 489846 tile = wpnsbuf[spr_death].tile;
4225
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 489846 times.
489846 if ( do_animation )
4227 {
4228
2/2
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS))
4229 {
4230
2/2
✓ Branch 0 taken 2184 times.
✓ Branch 1 taken 2 times.
2186 if(clk2 > 2)
4231 {
4232 2 spr_death_anim_clk=0;
4233 2 clk2=1;
4234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(hp > -1000)
4235 2 death_sfx();
4236 2 }
4237
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 91 times.
✓ Branch 3 taken 2 times.
2186 if(clk2==1 && spr_death_anim_clk>-1)
4238 {
4239 2 ++clk2;
4240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm=(spr_death_anim_clk/zc_max(wpnsbuf[spr_death].speed,1));
4241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm *= zc_max(1,txsz);
4242 2 int32_t rows = TILEROW(tile+spr_death_anim_frm)-TILEROW(tile);
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 spr_death_anim_frm += TILES_PER_ROW*(zc_min(0,tysz-1)*rows);
4244
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 if(++spr_death_anim_clk >= (zc_max(wpnsbuf[spr_death].speed,1) * zc_max(wpnsbuf[spr_death].frames,1)))
4245 {
4246 spr_death_anim_clk=-1;
4247 clk2=1;
4248 }
4249 2 }
4250 2186 tile += spr_death_anim_frm;
4251 2186 }
4252
2/2
✓ Branch 0 taken 79248 times.
✓ Branch 1 taken 408412 times.
487660 else if(BSZ)
4253
2/2
✓ Branch 0 taken 62313 times.
✓ Branch 1 taken 16935 times.
79248 tile += zc_min((15-clk2)/3,4);
4254
4/4
✓ Branch 0 taken 272202 times.
✓ Branch 1 taken 136210 times.
✓ Branch 2 taken 135966 times.
✓ Branch 3 taken 136236 times.
408412 else if(clk2>6 && clk2<=12)
4255 136236 ++tile;
4256 489846 }
4257
4258
6/6
✓ Branch 0 taken 487660 times.
✓ Branch 1 taken 2186 times.
✓ Branch 2 taken 408412 times.
✓ Branch 3 taken 79248 times.
✓ Branch 4 taken 125904 times.
✓ Branch 5 taken 282508 times.
489846 if(!get_qr(qr_HARDCODED_ENEMY_ANIMS) || BSZ || fading==fade_blue_poof)
4259 207338 cs = wpnsbuf[spr_death].csets&15;
4260 else
4261 282508 cs = (((clk2+5)>>1)&3)+6;
4262 489846 }
4263
2/2
✓ Branch 0 taken 22105172 times.
✓ Branch 1 taken 666510 times.
22771682 else if(hclk>0)
4264 {
4265
2/2
✓ Branch 0 taken 2916 times.
✓ Branch 1 taken 663594 times.
666510 if(family==eeGANON)
4266 2916 cs=(((hclk-1)>>1)&3)+6;
4267
4/4
✓ Branch 0 taken 619253 times.
✓ Branch 1 taken 44341 times.
✓ Branch 2 taken 110465 times.
✓ Branch 3 taken 508788 times.
663594 else if(hclk<33 && !get_qr(qr_ENEMIESFLICKER))
4268 508788 cs=(((hclk-1)>>1)&3)+6;
4269 666510 }
4270
4271
3/4
✓ Branch 0 taken 167600 times.
✓ Branch 1 taken 23093928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2948 times.
23264476 if((tmpscr->flags3&fINVISROOM) &&
4272
2/2
✓ Branch 0 taken 2948 times.
✓ Branch 1 taken 164652 times.
167600 !(current_item(itype_amulet)) &&
4273
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2948 times.
2948 !(get_qr(qr_LENSSEESENEMIES) &&
4274 2948 lensclk) && family!=eeGANON)
4275 {
4276 2948 sprite::drawcloaked(dest);
4277 2948 }
4278 else
4279 {
4280
6/6
✓ Branch 0 taken 23236088 times.
✓ Branch 1 taken 22492 times.
✓ Branch 2 taken 1090454 times.
✓ Branch 3 taken 22145634 times.
✓ Branch 4 taken 930949 times.
✓ Branch 5 taken 159505 times.
23258580 if(family !=eeGANON && hclk>0 && get_qr(qr_ENEMIESFLICKER))
4281 {
4282
2/2
✓ Branch 0 taken 15820 times.
✓ Branch 1 taken 143685 times.
159505 if((frame&1)==1)
4283 143685 sprite::drawzcboss(dest);
4284 159505 }
4285 else
4286 23099075 sprite::drawzcboss(dest);
4287 }
4288
4289 23261528 cs=cshold;
4290 23264120 }
4291
4292
4293 // similar to the overblock function--can do up to a 32x32 sprite
4294 //will this play nicely with scripttile, solely using the modifications in sprite::draw()?
4295 136827 void enemy::drawblock(BITMAP *dest,int32_t mask)
4296 {
4297 136827 int32_t thold=tile;
4298 136827 int32_t t1=tile;
4299 136827 int32_t t2=tile+20;
4300 136827 int32_t t3=tile+1;
4301 136827 int32_t t4=tile+21;
4302
4303
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 136827 times.
136827 switch(mask)
4304 {
4305 case 1:
4306 enemy::drawzcboss(dest);
4307 break;
4308
4309 case 3:
4310 if(flip&2)
4311 zc_swap(t1,t2);
4312
4313 tile=t1;
4314 enemy::drawzcboss(dest);
4315 tile=t2;
4316 yofs+=16;
4317 enemy::drawzcboss(dest);
4318 yofs-=16;
4319 break;
4320
4321 case 5:
4322 t2=tile+1;
4323
4324 if(flip&1)
4325 zc_swap(t1,t2);
4326
4327 tile=t1;
4328 enemy::drawzcboss(dest);
4329 tile=t2;
4330 xofs+=16;
4331 enemy::drawzcboss(dest);
4332 xofs-=16;
4333 break;
4334
4335 case 15:
4336
2/2
✓ Branch 0 taken 130714 times.
✓ Branch 1 taken 6113 times.
136827 if(flip&1)
4337 {
4338 6113 zc_swap(t1,t3);
4339 6113 zc_swap(t2,t4);
4340 6113 }
4341
4342
1/2
✓ Branch 0 taken 136827 times.
✗ Branch 1 not taken.
136827 if(flip&2)
4343 {
4344 zc_swap(t1,t2);
4345 zc_swap(t3,t4);
4346 }
4347
4348 136827 tile=t1;
4349 136827 enemy::drawzcboss(dest);
4350 136827 tile=t2;
4351 136827 yofs+=16;
4352 136827 enemy::drawzcboss(dest);
4353 136827 yofs-=16;
4354 136827 tile=t3;
4355 136827 xofs+=16;
4356 136827 enemy::drawzcboss(dest);
4357 136827 tile=t4;
4358 136827 yofs+=16;
4359 136827 enemy::drawzcboss(dest);
4360 136827 xofs-=16;
4361 136827 yofs-=16;
4362 136827 break;
4363 }
4364
4365 136827 tile=thold;
4366 136827 }
4367
4368 5845877 void enemy::drawshadow(BITMAP *dest, bool translucent)
4369 {
4370
4/4
✓ Branch 0 taken 5415173 times.
✓ Branch 1 taken 430704 times.
✓ Branch 2 taken 406089 times.
✓ Branch 3 taken 5009084 times.
5845877 if(dont_draw() || isSideViewGravity())
4371 {
4372 836793 return;
4373 }
4374
4375
2/2
✓ Branch 0 taken 80005 times.
✓ Branch 1 taken 4929079 times.
5009084 if(dying)
4376 {
4377 80005 return;
4378 }
4379
4380
4/4
✓ Branch 0 taken 2116 times.
✓ Branch 1 taken 4926963 times.
✓ Branch 2 taken 147668 times.
✓ Branch 3 taken 4781411 times.
4929079 if(((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))||
4381 4929079 (darkroom))
4382 {
4383 147668 return;
4384 }
4385 else
4386 {
4387
4/4
✓ Branch 0 taken 4563880 times.
✓ Branch 1 taken 217531 times.
✓ Branch 2 taken 4551272 times.
✓ Branch 3 taken 12608 times.
4781411 if(enemycanfall(id, false) && shadowtile == 0)
4388 12608 shadowtile = wpnsbuf[spr_shadow].tile;
4389
4390
5/6
✓ Branch 0 taken 4209361 times.
✓ Branch 1 taken 572050 times.
✓ Branch 2 taken 4209361 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3991830 times.
✓ Branch 5 taken 217531 times.
4781411 if(z>0 || fakez>0 || !enemycanfall(id, false))
4391 {
4392
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 789465 times.
789581 if(!shadow_overpit(this))
4393 789465 sprite::drawshadow(dest,translucent);
4394 789581 }
4395 }
4396 5845877 }
4397
4398 88213 void enemy::masked_draw(BITMAP *dest,int32_t mx,int32_t my,int32_t mw,int32_t mh)
4399 {
4400 88213 BITMAP *sub=create_sub_bitmap(dest,mx,my,mw,mh);
4401
4402
1/2
✓ Branch 0 taken 88213 times.
✗ Branch 1 not taken.
88213 if(sub!=NULL)
4403 {
4404 88213 xofs-=mx;
4405 88213 yofs-=my;
4406 88213 enemy::draw(sub);
4407 88213 xofs+=mx;
4408 88213 yofs+=my;
4409 88213 destroy_bitmap(sub);
4410 88213 }
4411 else
4412 enemy::draw(dest);
4413 88213 }
4414
4415 // override hit detection to check for invicibility, stunned, etc
4416 66872480 bool enemy::hit()
4417 {
4418
4/4
✓ Branch 0 taken 66047727 times.
✓ Branch 1 taken 824753 times.
✓ Branch 2 taken 64960106 times.
✓ Branch 3 taken 1087621 times.
66872480 if(dying || hclk>0) return false;
4419 64960106 return sprite::hit();
4420 66872480 }
4421 52704 bool enemy::hit(sprite *s)
4422 {
4423
3/4
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52264 times.
✓ Branch 3 taken 440 times.
52704 if(!hit() || !s->hit()) return false;
4424 52264 return sprite::hit(s);
4425 52704 }
4426
4427 27517195 bool enemy::hit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz2,int32_t tysz2,int32_t tzsz2)
4428 {
4429
2/2
✓ Branch 0 taken 2179304 times.
✓ Branch 1 taken 25337891 times.
27517195 if(!hit()) return false;
4430 25337891 return sprite::hit(tx,ty,tz,txsz2,tysz2,tzsz2);
4431 27517195 }
4432 bool enemy::hit(int32_t tx,int32_t ty,int32_t txsz2,int32_t tysz2)
4433 {
4434 if(!hit()) return false;
4435 return sprite::hit(tx,ty,txsz2,tysz2);
4436 }
4437
4438 7434715 bool enemy::hit(weapon *w)
4439 {
4440
2/2
✓ Branch 0 taken 851646 times.
✓ Branch 1 taken 6583069 times.
7434715 if(!hit()) return false;
4441
4442
2/2
✓ Branch 0 taken 6581733 times.
✓ Branch 1 taken 1336 times.
6583069 if (replay_version_check(0, 14))
4443 {
4444
4/6
✓ Branch 0 taken 6361773 times.
✓ Branch 1 taken 219960 times.
✓ Branch 2 taken 6361773 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6361773 times.
✗ Branch 5 not taken.
6581733 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk)
4445 219960 return false;
4446 6361773 return sprite::hit(w);
4447 }
4448 1336 return w->hit(this);
4449 7434715 }
4450
4451 6078176 bool enemy::can_pitfall(bool checkspawning)
4452 {
4453
4/4
✓ Branch 0 taken 6070221 times.
✓ Branch 1 taken 7955 times.
✓ Branch 2 taken 6068385 times.
✓ Branch 3 taken 9791 times.
6078176 if((fading||isspawning)&&checkspawning) return false; //Don't fall during spawn.
4454
2/2
✓ Branch 0 taken 6060917 times.
✓ Branch 1 taken 7468 times.
6068385 switch(guysbuf[id&0xFFF].family)
4455 {
4456 case eeAQUA:
4457 case eeDIG:
4458 case eeDONGO:
4459 case eeFAIRY:
4460 case eeGANON:
4461 case eeGHOMA:
4462 case eeGLEEOK:
4463 case eeGUY:
4464 case eeLANM:
4465 case eeMANHAN:
4466 case eeMOLD:
4467 case eeNONE:
4468 case eePATRA:
4469 case eeZORA:
4470 7468 return false; //Disallowed types
4471 default:
4472 6060917 return true;
4473 }
4474 6078176 }
4475 //Handle death
4476 21148622 void enemy::try_death(bool force_kill)
4477 {
4478
8/8
✓ Branch 0 taken 21107695 times.
✓ Branch 1 taken 40927 times.
✓ Branch 2 taken 21107693 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 24644 times.
✓ Branch 5 taken 21083049 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 24643 times.
21148622 if(!dying && (force_kill || (hp<=0 && !immortal)))
4479 {
4480 24645 std::vector<int32_t> &ev = FFCore.eventData;
4481 24645 ev.clear();
4482 24645 ev.push_back(10000);
4483 24645 ev.push_back(getUID());
4484
4485 24645 throwGenScriptEvent(GENSCR_EVENT_ENEMY_DEATH);
4486 24645 bool isSaved = !ev[0];
4487 24645 ev.clear();
4488
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24645 times.
24645 if(isSaved) return;
4489
4490
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 24621 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 22 times.
24645 if(itemguy && (hasitem&2)!=0)
4491 {
4492
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 22 times.
47 for(int32_t i=0; i<items.Count(); i++)
4493 {
4494
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 22 times.
25 if(((item*)items.spr(i))->pickup&ipENEMY)
4495 {
4496
1/2
✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
22 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
4497 {
4498 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
4499 {
4500 items.spr(i)->x = x+hxofs+(hit_width/2)-8;
4501 items.spr(i)->y = y+hyofs+(hit_height/2)-10-fakez;
4502 }
4503 else
4504 {
4505 if(extend >= 3)
4506 {
4507 items.spr(i)->x = x+(txsz-1)*8;
4508 items.spr(i)->y = y-2+(tysz-1)*8;
4509 }
4510 else
4511 {
4512 items.spr(i)->x = x;
4513 items.spr(i)->y = y - 2;
4514 }
4515 }
4516 items.spr(i)->z = z;
4517 items.spr(i)->fakez = fakez;
4518 }
4519 else
4520 {
4521 22 items.spr(i)->x = x;
4522 22 items.spr(i)->y = y - 2;
4523 }
4524 22 }
4525 25 }
4526 22 }
4527
4528 24645 dying=true;
4529
4530
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 24623 times.
24645 if(fading==fade_flash_die)
4531 22 clk2=19+18*4;
4532 else
4533 {
4534 24623 clk2 = BSZ ? 15 : 19;
4535
4536
2/2
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 17949 times.
24623 if(fading!=fade_blue_poof)
4537 17949 fading=0;
4538 }
4539
4540
2/2
✓ Branch 0 taken 24621 times.
✓ Branch 1 taken 24 times.
24645 if(itemguy)
4541 {
4542 24 hasitem&=~2;
4543 24 item_set=0;
4544 24 }
4545
4546
6/6
✓ Branch 0 taken 23961 times.
✓ Branch 1 taken 684 times.
✓ Branch 2 taken 19569 times.
✓ Branch 3 taken 4392 times.
✓ Branch 4 taken 644 times.
✓ Branch 5 taken 18925 times.
24645 if(currscr<128 && count_enemy && !script_spawned)
4547 18925 game->guys[(currmap<<7)+currscr]-=1;
4548 24645 }
4549 21148622 }
4550
4551 // --==**==--
4552
4553 // Movement routines that can be used by derived classes as needed
4554
4555 // --==**==--
4556
4557 324351 void enemy::fix_coords(bool bound)
4558 {
4559
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if ((get_qr(qr_OUTOFBOUNDSENEMIES) ? 1 : 0) ^ ((editorflags&ENEMY_FLAG11)?1:0)) return;
4560
1/2
✓ Branch 0 taken 324351 times.
✗ Branch 1 not taken.
324351 if(moveflags & FLAG_IGNORE_SCREENEDGE) bound = false;
4561
4562
4563
2/2
✓ Branch 0 taken 41509 times.
✓ Branch 1 taken 282842 times.
324351 if(bound)
4564 {
4565
1/2
✓ Branch 0 taken 282842 times.
✗ Branch 1 not taken.
282842 if ( ((unsigned)(id&0xFFF)) < MAXGUYS )
4566 {
4567
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 x=vbound(x, 0_zf, (( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_WIDTH && !isflier(id) ) ? (256_zf -((txsz-1)*16)) : 240_zf));
4568
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 282842 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
282842 y=vbound(y, 0_zf,(( guysbuf[id].SIZEflags&guyflagOVERRIDE_TILE_HEIGHT && !isflier(id) ) ? (176_zf -((txsz-1)*16)) : 160_zf));
4569 282842 }
4570 else
4571 {
4572 x=vbound(x, 0_zf,240_zf);
4573 y=vbound(y, 0_zf,160_zf);
4574 }
4575 282842 }
4576
4577
6/10
✓ Branch 0 taken 323337 times.
✓ Branch 1 taken 1014 times.
✓ Branch 2 taken 324351 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 324351 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 324351 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 324351 times.
324351 if(!OUTOFBOUNDS)
4578 {
4579 /*x=((int32_t(x)&0xF0)+((int32_t(x)&8)?16:0));
4580
4581 if(isSideViewGravity())
4582 y=((int32_t(y)&0xF8)+((int32_t(y)&4)?8:0));
4583 else
4584 y=((int32_t(y)&0xF0)+((int32_t(y)&8)?16:0));
4585 */
4586 324351 do_fix(x, 16, true);
4587
2/2
✓ Branch 0 taken 1014 times.
✓ Branch 1 taken 323337 times.
324351 if(isSideViewGravity())
4588 1014 do_fix(y,8,true);
4589 323337 else do_fix(y,16,true);
4590 324351 }
4591 324351 }
4592 6036 bool enemy::cannotpenetrate()
4593 {
4594
4/4
✓ Branch 0 taken 5919 times.
✓ Branch 1 taken 117 times.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 5900 times.
6036 return (family == eeAQUA || family == eeMANHAN || family == eeGHOMA);
4595 }
4596
4597 394 bool enemy::canmove_old(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
4598 {
4599 bool ok;
4600 394 int32_t dx = 0, dy = 0;
4601 394 int32_t sv = 8;
4602
4603 //Why is this here??? Why is it needed???
4604 394 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4605
4606
8/9
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 34 times.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 56 times.
✓ Branch 6 taken 43 times.
✓ Branch 7 taken 56 times.
✗ Branch 8 not taken.
394 switch(ndir)
4607 {
4608 case 8:
4609 case up:
4610
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
44 if(canfall(id) && isSideViewGravity())
4611 return false;
4612
4613 44 dy = dy1-s;
4614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 special = (special==spw_clipbottomright)?spw_none:special;
4615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4616 44 break;
4617
4618 case 12:
4619 case down:
4620
3/4
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 15 times.
✓ Branch 2 taken 25 times.
✗ Branch 3 not taken.
40 if(canfall(id) && isSideViewGravity())
4621 return false;
4622
4623 40 dy = dy2+s;
4624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 ok = !m_walkflag_old(x,y+dy,special, x, y) && !flyerblocked(x,y+dy, special);
4625 40 break;
4626
4627 case 14:
4628 case left:
4629 34 dx = dx1-s;
4630 34 sv = ((isSideViewGravity())?7:8);
4631
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4632
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
34 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4633 34 break;
4634
4635 case 10:
4636 case right:
4637 55 dx = dx2+s;
4638 55 sv = ((isSideViewGravity())?7:8);
4639
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 50 times.
55 ok = !m_walkflag_old(x+dx,y+sv,special, x, y) && !flyerblocked(x+dx,y+8, special);
4640 55 break;
4641
4642 case 9:
4643 case r_up:
4644 66 dx = dx2+s;
4645 66 dy = dy1-s;
4646
3/4
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 1 times.
131 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 65 times.
65 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4648 66 break;
4649
4650 case 11:
4651 case r_down:
4652 56 dx = dx2+s;
4653 56 dx = dy2+s;
4654
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4656 56 break;
4657
4658 case 13:
4659 case l_down:
4660 43 dx = dx1-s;
4661 43 dy = dy2+s;
4662
3/4
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
84 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
41 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4664 43 break;
4665
4666 case 15:
4667 case l_up:
4668 56 dx = dx1-s;
4669 56 dy = dy1-s;
4670
2/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
112 ok = !m_walkflag_old(x,y+dy,special, x, y) && !m_walkflag_old(x+dx,y+sv,special, x, y) &&
4671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
56 !flyerblocked(x,y+dy, special) && !flyerblocked(x+dx,y+8, special);
4672 56 break;
4673
4674 default:
4675 db=99;
4676 return true;
4677 }
4678
4679 394 return ok;
4680 394 }
4681
4682
4683
4684
4685 // returns true if next step is ok, false if there is something there
4686 3806334 bool enemy::canmove(int32_t ndir,zfix s,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2, bool kb)
4687 {
4688 3806334 bool ok = false; //initialise the var, son't just declare it
4689 3806334 int32_t dx = 0, dy = 0;
4690 3806334 int32_t sv = 8;
4691 3806334 int32_t tries = 2; int32_t try_x = 0; int32_t try_y = 0;
4692 //Why is this here??? Why is it needed???
4693 3806334 s += 0.5; // Make the ints round; doesn't seem to cause any problems.
4694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usexoffs = (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ? hxofs : 0;
4695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t useyoffs = (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ? hyofs : 0;
4696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4698 3806334 bool offgrid = OFFGRID_ENEMY;
4699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3806334 times.
3806334 if(!offgrid)
4700 {
4701 //Enemies smaller than 1-tile must act as 1-tile large, if off-grid movement is disabled.
4702
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usehei<16)usehei=16;
4703
1/2
✓ Branch 0 taken 3806334 times.
✗ Branch 1 not taken.
3806334 if(usewid<16)usewid=16;
4704 3806334 }
4705
9/9
✓ Branch 0 taken 708846 times.
✓ Branch 1 taken 565128 times.
✓ Branch 2 taken 629158 times.
✓ Branch 3 taken 634154 times.
✓ Branch 4 taken 290259 times.
✓ Branch 5 taken 347714 times.
✓ Branch 6 taken 321027 times.
✓ Branch 7 taken 306379 times.
✓ Branch 8 taken 3669 times.
3806334 switch(ndir) //need to check every 8 pixels between two points
4706 {
4707 case 8:
4708 case up:
4709 {
4710
4/4
✓ Branch 0 taken 96582 times.
✓ Branch 1 taken 612264 times.
✓ Branch 2 taken 95992 times.
✓ Branch 3 taken 590 times.
708846 if(enemycanfall(id) && isSideViewGravity())
4711 590 return false;
4712
4713 708256 dy = dy1-s;
4714
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 708253 times.
708256 special = (special==spw_clipbottomright)?spw_none:special;
4715 708256 tries = usewid/(offgrid ? 8 : 16);
4716 //Z_eventlog("Trying move UP, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4717
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 708256 times.
1316075 for ( ; tries > 0; --tries )
4718 {
4719
2/2
✓ Branch 0 taken 98395 times.
✓ Branch 1 taken 609861 times.
708256 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy, special,kb);
4720 708256 try_x += (offgrid ? 8 : 16);
4721
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if (!ok) break;
4722 607819 }
4723
2/2
✓ Branch 0 taken 607819 times.
✓ Branch 1 taken 100437 times.
708256 if(!ok) break;
4724
1/2
✓ Branch 0 taken 607819 times.
✗ Branch 1 not taken.
607819 if((usewid%16)>0) //Uneven width
4725 {
4726 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy, special,kb);
4727 }
4728 607819 break;
4729 }
4730 case 12:
4731 case down:
4732 {
4733
4/4
✓ Branch 0 taken 107028 times.
✓ Branch 1 taken 458100 times.
✓ Branch 2 taken 106340 times.
✓ Branch 3 taken 688 times.
565128 if(enemycanfall(id) && isSideViewGravity())
4734 688 return false;
4735
4736 564440 dy = dy2+s;
4737 564440 tries = usewid/(offgrid ? 8 : 16);
4738 //Z_eventlog("Trying move DOWN, dy=%d,usewid=%d,usehei=%d\n",int32_t(dy),usewid,usehei);
4739
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 564440 times.
1025090 for ( ; tries > 0; --tries )
4740 {
4741
3/4
✓ Branch 0 taken 103361 times.
✓ Branch 1 taken 461079 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 461079 times.
564440 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy,special, ndir, x+usexoffs+try_x, y+useyoffs, kb) && !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4742 564440 try_x += (offgrid ? 8 : 16);
4743
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if (!ok) break;
4744 460650 }
4745
2/2
✓ Branch 0 taken 460650 times.
✓ Branch 1 taken 103790 times.
564440 if(!ok) break;
4746
1/2
✓ Branch 0 taken 460650 times.
✗ Branch 1 not taken.
460650 if((usewid%16)>0) //Uneven width
4747 {
4748 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy,special, ndir, x+usexoffs+usewid-1, y+useyoffs, kb) && !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+zc_max(usehei-16,0), special,kb);
4749 }
4750 460650 break;
4751 }
4752 case 14:
4753 case left:
4754 {
4755 629158 dx = dx1-s;
4756 629158 sv = ((isSideViewGravity())?7:0);
4757
4/4
✓ Branch 0 taken 629152 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 1272 times.
✓ Branch 3 taken 627880 times.
629158 special = (special==spw_clipbottomright||special==spw_clipright)?spw_none:special;
4758 629158 tries = usehei/(offgrid ? 8 : 16);
4759 //Z_eventlog("Trying move LEFT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4760
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 629158 times.
1161818 for ( ; tries > 0; --tries )
4761 {
4762
2/2
✓ Branch 0 taken 95665 times.
✓ Branch 1 taken 533493 times.
629158 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+try_y, special,kb);
4763 629158 try_y += (offgrid ? 8 : 16);
4764
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if (!ok) break;
4765 532660 }
4766
2/2
✓ Branch 0 taken 532660 times.
✓ Branch 1 taken 96498 times.
629158 if(!ok) break;
4767
1/2
✓ Branch 0 taken 532660 times.
✗ Branch 1 not taken.
532660 if((usehei%16)>0) //Uneven height
4768 {
4769 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx,y+8+useyoffs+usehei-1, special,kb);
4770 }
4771 532660 break;
4772 }
4773 case 10:
4774 case right:
4775 {
4776 634154 dx = dx2+s;
4777 634154 sv = ((isSideViewGravity())?7:0);
4778 634154 tries = usehei/(offgrid ? 8 : 16);
4779 //Z_eventlog("Trying move RIGHT, dx=%d,usewid=%d,usehei=%d\n",int32_t(dx),usewid,usehei);
4780
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 634154 times.
1174344 for ( ; tries > 0; --tries )
4781 {
4782
3/4
✓ Branch 0 taken 93176 times.
✓ Branch 1 taken 540978 times.
✓ Branch 2 taken 540978 times.
✗ Branch 3 not taken.
634154 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+try_y+sv,special, ndir, x+usexoffs, y+useyoffs+try_y, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+try_y, special,kb);
4783 634154 try_y += (offgrid ? 8 : 16);
4784
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if (!ok) break;
4785 540190 }
4786
2/2
✓ Branch 0 taken 540190 times.
✓ Branch 1 taken 93964 times.
634154 if(!ok) break;
4787
1/2
✓ Branch 0 taken 540190 times.
✗ Branch 1 not taken.
540190 if((usehei%16)>0) //Uneven height
4788 {
4789 ok = !m_walkflag(x+usexoffs+dx,y+useyoffs+usehei-1+sv,special, ndir, x+usexoffs, y+useyoffs+usehei-1, kb) && !flyerblocked(x+usexoffs+dx+zc_max(usewid-16,0),y+8+useyoffs+usehei-1, special,kb);
4790 }
4791 540190 break;
4792 }
4793 case 9:
4794 case r_up:
4795 {
4796 290259 dx = dx2+s;
4797 290259 dy = dy1-s;
4798 290259 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4799 290259 sv = ((isSideViewGravity())?7:0);
4800
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_x > 0; --tries_x )
4801 {
4802 290259 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4803 290259 try_y = 0;
4804
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 290259 times.
571093 for ( ; tries_y > 0; --tries_y )
4805 {
4806
4/4
✓ Branch 0 taken 286282 times.
✓ Branch 1 taken 3977 times.
✓ Branch 2 taken 283302 times.
✓ Branch 3 taken 2980 times.
573561 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4807
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 281502 times.
283302 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4808 290259 try_y += (offgrid ? 8 : 16);
4809
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4810 280834 }
4811
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if (!ok) break;
4812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280834 times.
280834 if((usehei%16)>0) //Uneven height
4813 {
4814 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4815 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4816 }
4817 280834 try_x += (offgrid ? 8 : 16);
4818 280834 }
4819
2/2
✓ Branch 0 taken 280834 times.
✓ Branch 1 taken 9425 times.
290259 if(!ok) break;
4820
1/2
✓ Branch 0 taken 280834 times.
✗ Branch 1 not taken.
280834 if((usewid%16)>0) //Uneven width
4821 {
4822 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4823 try_y = 0;
4824 for ( ; tries_y > 0; --tries_y )
4825 {
4826 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4827 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4828 try_y += (offgrid ? 8 : 16);
4829 if (!ok) break;
4830 }
4831 if (!ok) break;
4832 if((usehei%16)>0) //Uneven height
4833 {
4834 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4835 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4836 }
4837 }
4838 280834 break;
4839 }
4840 case 11:
4841 case r_down:
4842 {
4843 347714 dx = dx2+s;
4844 347714 dx = dy2+s;
4845 347714 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4846 //sv = ((isSideViewGravity())?7:0);
4847
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_x > 0; --tries_x )
4848 {
4849 347714 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4850 347714 try_y = 0;
4851
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 347714 times.
687537 for ( ; tries_y > 0; --tries_y )
4852 {
4853
4/4
✓ Branch 0 taken 347575 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 340363 times.
✓ Branch 3 taken 7212 times.
688077 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4854
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 340321 times.
340363 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4855 347714 try_y += (offgrid ? 8 : 16);
4856
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4857 339823 }
4858
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if (!ok) break;
4859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339823 times.
339823 if((usehei%16)>0) //Uneven height
4860 {
4861 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4862 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4863 }
4864 339823 try_x += (offgrid ? 8 : 16);
4865 339823 }
4866
2/2
✓ Branch 0 taken 339823 times.
✓ Branch 1 taken 7891 times.
347714 if(!ok) break;
4867
1/2
✓ Branch 0 taken 339823 times.
✗ Branch 1 not taken.
339823 if((usewid%16)>0) //Uneven width
4868 {
4869 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4870 try_y = 0;
4871 for ( ; tries_y > 0; --tries_y )
4872 {
4873 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4874 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4875 try_y += (offgrid ? 8 : 16);
4876 if (!ok) break;
4877 }
4878 if (!ok) break;
4879 if((usehei%16)>0) //Uneven height
4880 {
4881 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4882 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4883 }
4884 }
4885 339823 break;
4886 }
4887 case 13:
4888 case l_down:
4889 {
4890 321027 dx = dx1-s;
4891 321027 dy = dy2+s;
4892 321027 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4893 //sv = ((isSideViewGravity())?7:0);
4894
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_x > 0; --tries_x )
4895 {
4896 321027 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4897 321027 try_y = 0;
4898
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 321027 times.
633935 for ( ; tries_y > 0; --tries_y )
4899 {
4900
4/4
✓ Branch 0 taken 315731 times.
✓ Branch 1 taken 5296 times.
✓ Branch 2 taken 313353 times.
✓ Branch 3 taken 2378 times.
634380 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4901
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 313025 times.
313353 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4902 321027 try_y += (offgrid ? 8 : 16);
4903
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4904 312908 }
4905
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if (!ok) break;
4906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 312908 times.
312908 if((usehei%16)>0) //Uneven height
4907 {
4908 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4909 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4910 }
4911 312908 try_x += (offgrid ? 8 : 16);
4912 312908 }
4913
2/2
✓ Branch 0 taken 312908 times.
✓ Branch 1 taken 8119 times.
321027 if(!ok) break;
4914
1/2
✓ Branch 0 taken 312908 times.
✗ Branch 1 not taken.
312908 if((usewid%16)>0) //Uneven width
4915 {
4916 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4917 try_y = 0;
4918 for ( ; tries_y > 0; --tries_y )
4919 {
4920 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4921 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4922 try_y += (offgrid ? 8 : 16);
4923 if (!ok) break;
4924 }
4925 if (!ok) break;
4926 if((usehei%16)>0) //Uneven height
4927 {
4928 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4929 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4930 }
4931 }
4932 312908 break;
4933 }
4934 case 15:
4935 case l_up:
4936 {
4937 306379 dx = dx1-s;
4938 306379 dy = dy1-s;
4939 306379 int32_t tries_x = usewid/(offgrid ? 8 : 16);
4940 306379 sv = ((isSideViewGravity())?7:0);
4941
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_x > 0; --tries_x )
4942 {
4943 306379 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4944 306379 try_y = 0;
4945
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 306379 times.
603796 for ( ; tries_y > 0; --tries_y )
4946 {
4947
4/4
✓ Branch 0 taken 302185 times.
✓ Branch 1 taken 4194 times.
✓ Branch 2 taken 299965 times.
✓ Branch 3 taken 2220 times.
606344 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+try_x, y+useyoffs+try_y, kb) &&
4948
2/2
✓ Branch 0 taken 1918 times.
✓ Branch 1 taken 298047 times.
299965 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+try_y, special,kb);
4949 306379 try_y += (offgrid ? 8 : 16);
4950
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4951 297417 }
4952
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if (!ok) break;
4953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 297417 times.
297417 if((usehei%16)>0) //Uneven height
4954 {
4955 ok = !m_walkflag(x+usexoffs+try_x,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+try_x,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+try_x, y+useyoffs+usehei-1, kb) &&
4956 !flyerblocked(x+usexoffs+try_x,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+try_x,y+useyoffs+8+usehei-1, special,kb);
4957 }
4958 297417 try_x += (offgrid ? 8 : 16);
4959 297417 }
4960
2/2
✓ Branch 0 taken 297417 times.
✓ Branch 1 taken 8962 times.
306379 if(!ok) break;
4961
1/2
✓ Branch 0 taken 297417 times.
✗ Branch 1 not taken.
297417 if((usewid%16)>0) //Uneven width
4962 {
4963 int32_t tries_y = usehei/(offgrid ? 8 : 16);
4964 try_y = 0;
4965 for ( ; tries_y > 0; --tries_y )
4966 {
4967 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+try_y,special,ndir, x+usexoffs+usewid-1, y+useyoffs+try_y, kb) &&
4968 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+try_y, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+try_y, special,kb);
4969 try_y += (offgrid ? 8 : 16);
4970 if (!ok) break;
4971 }
4972 if (!ok) break;
4973 if((usehei%16)>0) //Uneven height
4974 {
4975 ok = !m_walkflag(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) && !m_walkflag(x+usexoffs+dx+usewid-1,y+useyoffs+sv+usehei-1,special,ndir, x+usexoffs+usewid-1, y+useyoffs+usehei-1, kb) &&
4976 !flyerblocked(x+usexoffs+usewid-1,y+useyoffs+dy+usehei-1, special,kb) && !flyerblocked(x+usexoffs+dx+usewid-1,y+useyoffs+8+usehei-1, special,kb);
4977 }
4978 }
4979 297417 break;
4980 }
4981 default:
4982 3669 db=99;
4983 3669 return true;
4984 }
4985 //Z_eventlog("\n");
4986 3801387 return ok;
4987 3806334 }
4988
4989
4990 2471516 bool enemy::canmove(int32_t ndir,zfix s,int32_t special, bool kb)
4991 {
4992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
4993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2471516 times.
2471516 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
4994
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
4995
1/2
✓ Branch 0 taken 2471516 times.
✗ Branch 1 not taken.
2471516 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
4996 2471516 --usewid;
4997 2471516 --usehei;
4998 2471516 return canmove(ndir,s,special,0,-8,usewid,usehei,kb);
4999 }
5000
5001 663823 bool enemy::canmove(int32_t ndir,int32_t special, bool kb)
5002 {
5003 663823 bool dodongo_move=true; //yes, it's an ugly hack, but we're going to rewrite everything later anyway - DN
5004
5005
4/4
✓ Branch 0 taken 4788 times.
✓ Branch 1 taken 659035 times.
✓ Branch 2 taken 3596 times.
✓ Branch 3 taken 1192 times.
663823 if(special==spw_clipright&&ndir==right)
5006 {
5007 1192 dodongo_move=canmove(ndir,(zfix)1,special,0,-8,31,15,kb);
5008 1192 }
5009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usewid = (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ? hit_width : 16;
5010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 663823 times.
663823 int32_t usehei = (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ? hit_height : 16;
5011
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usewid % 16 != 0) usewid += (16 - (usewid%16));
5012
1/2
✓ Branch 0 taken 663823 times.
✗ Branch 1 not taken.
663823 if (usehei % 16 != 0) usehei += (16 - (usehei%16));
5013 663823 --usewid;
5014 663823 --usehei;
5015
2/2
✓ Branch 0 taken 357484 times.
✓ Branch 1 taken 306339 times.
663823 return canmove(ndir,(zfix)1,special,0,-8,usewid,usehei,kb)&&dodongo_move;
5016 }
5017
5018 65432 bool enemy::canmove(int32_t ndir, bool kb)
5019 {
5020 65432 return canmove(ndir,(zfix)1,spw_none,0,-8,15,15,kb);
5021 }
5022
5023 // 8-directional
5024 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5025 {
5026 394 int32_t ndir=0;
5027
5028 // can move straight, check if it wants to turn
5029
2/2
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 9 times.
394 if(canmove_old(dir,step,special,dx1,dy1,dx2,dy2))
5030 {
5031
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(grumble && (zc_oldrand()&4)<grumble) //Homing
5032 {
5033 int32_t w = Lwpns.idFirst(wBait);
5034
5035 if(w>=0)
5036 {
5037 int32_t bx = Lwpns.spr(w)->x;
5038 int32_t by = Lwpns.spr(w)->y;
5039
5040 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5041
5042 if(abs(int32_t(y)-by)>14)
5043 {
5044 if(ndir>0) // Already left or right
5045 {
5046 // Making the diagonal directions
5047 ndir += (by<y) ? 2 : 4;
5048 }
5049 else
5050 {
5051 ndir = (by<y) ? up : down;
5052 }
5053 }
5054
5055 if(canmove(ndir,special,false))
5056 {
5057 dir=ndir;
5058 return;
5059 }
5060 }
5061 }
5062
5063 // Homing added.
5064
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 385 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
385 if(newhoming && (zc_oldrand()&255)<newhoming)
5065 {
5066 ndir = lined_up(8,true);
5067
5068 if(ndir>=0 && canmove(ndir,special,false))
5069 {
5070 dir=ndir;
5071 }
5072
5073 return;
5074 }
5075
5076 385 int32_t r=zc_oldrand();
5077
5078
2/4
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
385 if(newrate>0 && !(r%newrate))
5079 {
5080 385 ndir = ((dir+((r&64)?-1:1))&7)+8;
5081 385 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5082
5083
2/2
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
385 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5084 371 dir=ndir;
5085
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11 times.
14 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5086 11 dir=ndir2;
5087
5088
3/4
✓ Branch 0 taken 371 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 371 times.
✗ Branch 3 not taken.
385 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5089 // due to numerous lost fractional components. -L
5090 {
5091 x.doFloor();
5092 y.doFloor();
5093 }
5094 385 }
5095
5096 385 return;
5097 }
5098
5099 // can't move straight, must turn
5100 9 int32_t i=0;
5101
5102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 for(; i<32; i++) // Try random dir
5103 {
5104 16 ndir=(zc_oldrand()&7)+8;
5105
5106
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 9 times.
16 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5107 9 break;
5108 7 }
5109
5110
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(i==32)
5111 {
5112 for(ndir=8; ndir<16; ndir++)
5113 {
5114 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5115 goto ok;
5116 }
5117
5118 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5119 }
5120
5121 ok:
5122 9 dir=ndir;
5123 9 x.doFloor();
5124 9 y.doFloor();
5125 394 }
5126
5127 311413 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
5128 {
5129 311413 int32_t ndir=0;
5130
5131 // can move straight, check if it wants to turn
5132
2/2
✓ Branch 0 taken 293564 times.
✓ Branch 1 taken 17849 times.
311413 if(canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
5133 {
5134
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 293357 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 101 times.
293564 if(grumble && (zc_oldrand()&4)<abs(grumble)) //Homing
5135 {
5136 101 int32_t i = Lwpns.idFirst(wBait);
5137
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if(i >= 0) //idfirst returns -1 if it can't find any
5138 {
5139 weapon *w = (weapon*)Lwpns.spr(i);
5140 if (get_qr(qr_FIND_CLOSEST_BAIT))
5141 {
5142 int32_t currentrange;
5143 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5144 else currentrange = -1;
5145 int curid = i;
5146 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5147 for(; i<Lwpns.Count(); ++i)
5148 {
5149 weapon *lw = (weapon*)Lwpns.spr(i);
5150 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5151 {
5152 currentrange = distance(x, y, lw->x, lw->y);
5153 curid = i;
5154 }
5155 }
5156 i = curid;
5157 if (currentrange == -1) i = -1;
5158 }
5159 else
5160 {
5161 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5162 }
5163 if(i>=0)
5164 {
5165 int32_t bx = Lwpns.spr(i)->x;
5166 int32_t by = Lwpns.spr(i)->y;
5167
5168 ndir = (bx<x) ? left : (bx!=x) ? right : 0;
5169
5170 if(abs(int32_t(y)-by)>14)
5171 {
5172 if(ndir>0) // Already left or right
5173 {
5174 // Making the diagonal directions
5175 ndir += (by<y) ? 2 : 4;
5176 }
5177 else
5178 {
5179 ndir = (by<y) ? up : down;
5180 }
5181 }
5182 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5183 if(canmove(ndir,special,false))
5184 {
5185 dir=ndir;
5186 return;
5187 }
5188 }
5189 }
5190 101 }
5191
5192 // Homing added.
5193
4/4
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 292999 times.
✓ Branch 2 taken 409 times.
✓ Branch 3 taken 156 times.
293564 if(newhoming && (zc_oldrand()&255)<abs(newhoming))
5194 {
5195 156 ndir = lined_up(8,true);
5196
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
156 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5197
4/4
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 87 times.
156 if(ndir>=0 && canmove(ndir,special,false))
5198 {
5199 87 dir=ndir;
5200 87 }
5201
5202 156 return;
5203 }
5204
5205 293408 int32_t r=zc_oldrand();
5206
5207
4/4
✓ Branch 0 taken 184141 times.
✓ Branch 1 taken 109267 times.
✓ Branch 2 taken 99386 times.
✓ Branch 3 taken 84755 times.
293408 if(newrate>0 && !(r%newrate))
5208 {
5209 84755 ndir = ((dir+((r&64)?-1:1))&7)+8;
5210 84755 int32_t ndir2=((dir+((r&64)?1:-1))&7)+8;
5211
5212
2/2
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
84755 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5213 81873 dir=ndir;
5214
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 2702 times.
2882 else if(canmove(ndir2,step,special,dx1,dy1,dx2,dy2,false))
5215 2702 dir=ndir2;
5216
5217
4/4
✓ Branch 0 taken 81873 times.
✓ Branch 1 taken 2882 times.
✓ Branch 2 taken 77990 times.
✓ Branch 3 taken 3883 times.
84755 if(dir==ndir && (newrate>=4)) // newrate>=4, otherwise movement is biased toward upper-left
5218 // due to numerous lost fractional components. -L
5219 {
5220 3883 x.doFloor();
5221 3883 y.doFloor();
5222 3883 }
5223 84755 }
5224
5225 293408 return;
5226 }
5227
5228 // can't move straight, must turn
5229 17849 int32_t i=0;
5230
5231
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 33819 times.
33847 for(; i<32; i++) // Try random dir
5232 {
5233 33819 ndir=(zc_oldrand()&7)+8;
5234
5235
2/2
✓ Branch 0 taken 15998 times.
✓ Branch 1 taken 17821 times.
33819 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5236 17821 break;
5237 15998 }
5238
5239
2/2
✓ Branch 0 taken 17821 times.
✓ Branch 1 taken 28 times.
17866 if(i==32)
5240 {
5241
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 17 times.
172 for(ndir=8; ndir<16; ndir++)
5242 {
5243
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 11 times.
155 if(canmove(ndir,step,special,dx1,dy1,dx2,dy2,false))
5244 11 goto ok;
5245 144 }
5246
5247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5248 17 }
5249
5250 ok:
5251 17849 dir=ndir;
5252 17849 x.doFloor();
5253 17849 y.doFloor();
5254 311413 }
5255
5256 307935 void enemy::newdir_8(int32_t newrate,int32_t newhoming,int32_t special)
5257 {
5258 307935 newdir_8(newrate,newhoming,special,0,-8,15,15);
5259 307935 }
5260
5261 394 void enemy::newdir_8_old(int32_t newrate,int32_t newhoming,int32_t special)
5262 {
5263 394 newdir_8_old(newrate,newhoming,special,0,-8,15,15);
5264 394 }
5265
5266 // makes the enemy slide backwards when hit
5267 // sclk: first byte is clk, second byte is dir
5268 // makes the enemy slide backwards when hit
5269 // sclk: first byte is clk, second byte is dir
5270 9376002 int32_t enemy::slide()
5271 {
5272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9376002 times.
9376002 if(script_knockback_clk!=0) //scripted knockback
5273 {
5274 sclk = 0;
5275 return 1; //scripted knockback ran
5276 }
5277
5/6
✓ Branch 0 taken 55775 times.
✓ Branch 1 taken 9320227 times.
✓ Branch 2 taken 5384 times.
✓ Branch 3 taken 50391 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5384 times.
9376002 if(sclk==0 || (hp<=0 && !immortal))
5278 9325611 return 0;
5279
5280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50391 times.
50391 if(knockbackflags & FLAG_NOSLIDE)
5281 {
5282 sclk = 0;
5283 if(!OFFGRID_ENEMY)
5284 {
5285 //Fix to grid
5286 //x = (int32_t(x)+8)-((int32_t(x)+8)%16);
5287 //y = (int32_t(y)+8)-((int32_t(y)+8)%16);
5288 do_fix(x, 16, true);
5289 do_fix(y, 16, true);
5290 }
5291 return 0;
5292 }
5293
8/10
✓ Branch 0 taken 5089 times.
✓ Branch 1 taken 45302 times.
✓ Branch 2 taken 25 times.
✓ Branch 3 taken 5064 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 25 times.
✓ Branch 6 taken 3796 times.
✓ Branch 7 taken 1268 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 25 times.
50391 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,0,0,15,15,true)))
5294 {
5295 1268 sclk=0;
5296 1268 return 0;
5297 }
5298
5299 49123 --sclk;
5300
5301
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 6052 times.
✓ Branch 2 taken 6364 times.
✓ Branch 3 taken 16287 times.
✓ Branch 4 taken 18763 times.
49123 switch(sclk>>8)
5302 {
5303 case up:
5304 {
5305
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5378 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 6046 times.
6052 if(y<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0))) //vires
5306 {
5307 6 sclk=0;
5308 6 return 0;
5309 }
5310
4/4
✓ Branch 0 taken 674 times.
✓ Branch 1 taken 5372 times.
✓ Branch 2 taken 564 times.
✓ Branch 3 taken 110 times.
6046 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5311
5312 5936 break;
5313 }
5314 case down:
5315 {
5316
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6362 times.
6364 if(y>=(dmisc2==e2tSPLITHIT ? 150 : 160)) //was 160 --changed for vires bug.
5317 {
5318 2 sclk=0;
5319 2 return 0;
5320 }
5321
4/4
✓ Branch 0 taken 769 times.
✓ Branch 1 taken 5593 times.
✓ Branch 2 taken 668 times.
✓ Branch 3 taken 101 times.
6362 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5322
5323 6261 break;
5324 }
5325 case left:
5326 {
5327
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14874 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 16274 times.
16287 if(x<=(dmisc2==e2tSPLITHIT ? 0 : (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION)?16:0)))
5328 {
5329 13 sclk=0;
5330 13 return 0;
5331 }
5332
4/4
✓ Branch 0 taken 1413 times.
✓ Branch 1 taken 14861 times.
✓ Branch 2 taken 1295 times.
✓ Branch 3 taken 118 times.
16274 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; }
5333
5334 16156 break;
5335 }
5336 case right:
5337 {
5338
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18763 times.
18763 if(x>=(dmisc2==e2tSPLITHIT ? 255 : 240)) //vires
5339 {
5340 sclk=0;
5341 return 0;
5342 }
5343
4/4
✓ Branch 0 taken 2361 times.
✓ Branch 1 taken 16402 times.
✓ Branch 2 taken 2195 times.
✓ Branch 3 taken 166 times.
18763 if ( dmisc2==e2tSPLITHIT && !canmove(sclk>>8,(zfix)(4),0,true) ) { sclk=0; return 0; } //vires
5344 18597 break;
5345 }
5346 }
5347
5348 48607 int32_t move = knockbackSpeed;
5349
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 48607 times.
94695 while(move>0)
5350 {
5351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48607 times.
48607 int32_t thismove = zc_min(8, move);
5352 48607 move -= thismove;
5353 48607 hitdir = (sclk>>8);
5354
5/5
✓ Branch 0 taken 1657 times.
✓ Branch 1 taken 5936 times.
✓ Branch 2 taken 6261 times.
✓ Branch 3 taken 16156 times.
✓ Branch 4 taken 18597 times.
48607 switch(sclk>>8)
5355 {
5356 case up:
5357 5936 y-=thismove;
5358 5936 break;
5359
5360 case down:
5361 6261 y+=thismove;
5362 6261 break;
5363
5364 case left:
5365 16156 x-=thismove;
5366 16156 break;
5367
5368 case right:
5369 18597 x+=thismove;
5370 18597 break;
5371 }
5372
2/2
✓ Branch 0 taken 46088 times.
✓ Branch 1 taken 2519 times.
48607 if(!canmove(sclk>>8,(zfix)0,0,true))
5373 {
5374
3/3
✓ Branch 0 taken 1055 times.
✓ Branch 1 taken 1460 times.
✓ Branch 2 taken 4 times.
2519 switch(sclk>>8)
5375 {
5376 case up:
5377 case down:
5378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1055 times.
1055 if(y < 0)
5379 y = 0;
5380
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 865 times.
1055 else if((int32_t(y)&15) > 7)
5381 190 y=(int32_t(y)&0xF0)+16;
5382 else
5383 865 y=(int32_t(y)&0xF0);
5384
5385 1055 break;
5386
5387 case left:
5388 case right:
5389
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1459 times.
1460 if(x < 0)
5390 1 x = 0;
5391
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 1027 times.
1459 else if((int32_t(x)&15) > 7)
5392 432 x=(int32_t(x)&0xF0)+16;
5393 else
5394 1027 x=(int32_t(x)&0xF0);
5395
5396 1460 break;
5397 }
5398
5399 2519 sclk=0;
5400 2519 clk3=0;
5401 2519 break;
5402 }
5403 }
5404
5405
2/2
✓ Branch 0 taken 44810 times.
✓ Branch 1 taken 3797 times.
48607 if((sclk&255)==0)
5406 {
5407 //hitdir = -1;
5408 3797 sclk=0;
5409 3797 }
5410 48607 return 2;
5411 9376002 }
5412
5413 bool enemy::can_slide()
5414 {
5415 if(sclk==0 || (hp<=0 && !immortal))
5416 return false;
5417
5418 if((sclk&255)==16 && (get_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION) || knockbackSpeed!=4 ? !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : 12),0,true) : !canmove(sclk>>8,(zfix) (dmisc2==e2tSPLITHIT ? 1 : knockbackSpeed),0,true)))
5419 {
5420 return false;
5421 }
5422
5423 return true;
5424 }
5425
5426 bool enemy::fslide()
5427 {
5428 if(sclk==0 || (hp<=0 && !immortal))
5429 return false;
5430
5431 if((sclk&255)==16 && !canmove(sclk>>8,(zfix)12,spw_floater,true))
5432 {
5433 sclk=0;
5434 return false;
5435 }
5436
5437 --sclk;
5438
5439 switch(sclk>>8)
5440 {
5441 case up:
5442 if(y<=16)
5443 {
5444 sclk=0;
5445 return false;
5446 }
5447
5448 break;
5449
5450 case down:
5451 if(y>=160)
5452 {
5453 sclk=0;
5454 return false;
5455 }
5456
5457 break;
5458
5459 case left:
5460 if(x<=16)
5461 {
5462 sclk=0;
5463 return false;
5464 }
5465
5466 break;
5467
5468 case right:
5469 if(x>=240)
5470 {
5471 sclk=0;
5472 return false;
5473 }
5474
5475 break;
5476 }
5477 hitdir = (sclk>>8);
5478 switch(sclk>>8)
5479 {
5480 case up:
5481 y-=4;
5482 break;
5483
5484 case down:
5485 y+=4;
5486 break;
5487
5488 case left:
5489 x-=4;
5490 break;
5491
5492 case right:
5493 x+=4;
5494 break;
5495 }
5496
5497 if(!canmove(sclk>>8,(zfix)0,spw_floater,true))
5498 {
5499 switch(sclk>>8)
5500 {
5501 case up:
5502 case down:
5503 if((int32_t(y)&15) > 7)
5504 y=(int32_t(y)&0xF0)+16;
5505 else
5506 y=(int32_t(y)&0xF0);
5507
5508 break;
5509
5510 case left:
5511 case right:
5512 if((int32_t(x)&15) > 7)
5513 x=(int32_t(x)&0xF0)+16;
5514 else
5515 x=(int32_t(x)&0xF0);
5516
5517 break;
5518 }
5519
5520 sclk=0;
5521 clk3=0;
5522 }
5523
5524 if((sclk&255)==0)
5525 sclk=0;
5526
5527 return true;
5528 }
5529
5530 bool enemy::knockback(int32_t time, int32_t dir, int32_t speed)
5531 {
5532 if((hp<=0 && !immortal)) return false; //No knocking back dead/mid-knockback enemies
5533 if(!canmove(dir,(zfix)speed,0,0,0,15,15,true)) return false; //from slide(); collision check
5534 bool ret = sprite::knockback(time, dir, speed);
5535 if(ret) sclk = 0; //kill engine knockback if interrupted
5536 //! Perhaps also set hitdir here, if needed for timing? -Z
5537 return ret;
5538 }
5539
5540 21148620 bool enemy::runKnockback()
5541 {
5542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21148620 times.
21148620 if((script_knockback_clk&0xFF)==0)
5543 {
5544 21148620 script_knockback_clk = 0;
5545 21148620 return false;
5546 }
5547 if(knockbackflags & FLAG_NOSCRIPTKNOCKBACK)
5548 {
5549 return false;
5550 }
5551 int32_t move = script_knockback_speed;
5552 int32_t kb_dir = script_knockback_clk>>8;
5553 --script_knockback_clk;
5554
5555 while(move>0)
5556 {
5557 int32_t thismove = zc_min(get_qr(qr_OLD_SCRIPTED_KNOCKBACK)?8:4, move);
5558 move -= thismove;
5559 hitdir = kb_dir;
5560 switch(kb_dir)
5561 {
5562 case r_up:
5563 case l_up:
5564 case up:
5565 y-=thismove;
5566 break;
5567
5568 case r_down:
5569 case l_down:
5570 case down:
5571 y+=thismove;
5572 break;
5573 }
5574 switch(kb_dir)
5575 {
5576 case l_up:
5577 case l_down:
5578 case left:
5579 x-=thismove;
5580 break;
5581
5582 case r_up:
5583 case r_down:
5584 case right:
5585 x+=thismove;
5586 break;
5587 }
5588 if (get_qr(qr_OLD_SCRIPTED_KNOCKBACK))
5589 {
5590 if(!canmove(kb_dir,(zfix)0,0,true))
5591 {
5592 script_knockback_clk=0;
5593 clk3=0;
5594 //Fix to grid
5595 switch(kb_dir)
5596 {
5597 case up:
5598 case down:
5599 break;
5600 default:
5601 if(x < 0)
5602 x = 0;
5603 else if((int32_t(x)&15) > 7)
5604 x=(int32_t(x)&0xF0)+16;
5605 else
5606 x=(int32_t(x)&0xF0);
5607 break;
5608 }
5609 switch(kb_dir)
5610 {
5611 case left:
5612 case right:
5613 break;
5614 default:
5615 if(y < 0)
5616 y = 0;
5617 else if((int32_t(y)&15) > 7)
5618 y=(int32_t(y)&0xF0)+16;
5619 else
5620 y=(int32_t(y)&0xF0);
5621 break;
5622 }
5623 break;
5624 }
5625 }
5626 else
5627 {
5628 if(!scr_canplace(x,y,0,true))
5629 {
5630 script_knockback_clk=0;
5631 clk3=0;
5632 //Fix to grid
5633 if (OFFGRID_ENEMY)
5634 {
5635 switch(kb_dir)
5636 {
5637 case up:
5638 case down:
5639 break;
5640 default:
5641 if(x < 0)
5642 x = 0;
5643 else if((int32_t(x)&7) > 3)
5644 x=(int32_t(x)&0xF8)+8;
5645 else
5646 x=(int32_t(x)&0xF8);
5647 break;
5648 }
5649 switch(kb_dir)
5650 {
5651 case left:
5652 case right:
5653 break;
5654 default:
5655 if(y < 0)
5656 y = 0;
5657 else if((int32_t(y)&7) > 3)
5658 y=(int32_t(y)&0xF8)+8;
5659 else
5660 y=(int32_t(y)&0xF8);
5661 break;
5662 }
5663 }
5664 else
5665 {
5666 switch(kb_dir)
5667 {
5668 case up:
5669 case down:
5670 break;
5671 default:
5672 if(x < 0)
5673 x = 0;
5674 else if((int32_t(x)&15) > 7)
5675 x=(int32_t(x)&0xF0)+16;
5676 else
5677 x=(int32_t(x)&0xF0);
5678 break;
5679 }
5680 switch(kb_dir)
5681 {
5682 case left:
5683 case right:
5684 break;
5685 default:
5686 if(y < 0)
5687 y = 0;
5688 else if((int32_t(y)&15) > 7)
5689 y=(int32_t(y)&0xF0)+16;
5690 else
5691 y=(int32_t(y)&0xF0);
5692 break;
5693 }
5694 }
5695 break;
5696 }
5697
5698 }
5699 }
5700 return true;
5701 21148620 }
5702 // changes enemy's direction, checking restrictions
5703 // rate: 0 = no random changes, 16 = always random change
5704 // homing: 0 = none, 256 = always
5705 // grumble 0 = none, 4 = strongest appetite
5706 306188 void enemy::newdir(int32_t newrate,int32_t newhoming,int32_t special)
5707 {
5708 306188 int32_t ndir=-1;
5709
5710
4/4
✓ Branch 0 taken 73847 times.
✓ Branch 1 taken 232341 times.
✓ Branch 2 taken 26089 times.
✓ Branch 3 taken 47758 times.
306188 if(grumble != 0 && (zc_oldrand()&3)<abs(grumble)) //yes, I know checking if grumble is equal to if grumble == 0, but the latter makes the intention more clear to less experienced coders who might join.
5711 {
5712 47758 int32_t i = Lwpns.idFirst(wBait);
5713
1/2
✓ Branch 0 taken 47758 times.
✗ Branch 1 not taken.
47758 if(i >= 0) //idfirst returns -1 if it can't find any
5714 {
5715 weapon *w = (weapon*)Lwpns.spr(i);
5716 if (get_qr(qr_FIND_CLOSEST_BAIT))
5717 {
5718 int32_t currentrange;
5719 if (distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0) currentrange = distance(x, y, w->x, w->y);
5720 else currentrange = -1;
5721 int curid = i;
5722 ++i; //increment beforehand cause we just checked the first bait weapon and all others must be after it. ...otherwise it wouldn't be the first. -Deedee
5723 for(; i<Lwpns.Count(); ++i)
5724 {
5725 weapon *lw = (weapon*)Lwpns.spr(i);
5726 if (lw->id == wBait && distance(x, y, lw->x, lw->y) < currentrange && (distance(x, y, lw->x, lw->y) < lw->misc2 || lw->misc2 == 0))
5727 {
5728 currentrange = distance(x, y, lw->x, lw->y);
5729 curid = i;
5730 }
5731 }
5732 i = curid;
5733 if (currentrange == -1) i = -1;
5734 }
5735 else
5736 {
5737 if (!(distance(x, y, w->x, w->y) < w->misc2 || w->misc2 == 0)) i = -1;
5738 }
5739 if (i >= 0)
5740 {
5741 int32_t bx = Lwpns.spr(i)->x;
5742 int32_t by = Lwpns.spr(i)->y;
5743
5744 if(abs(int32_t(y)-by)>14)
5745 {
5746 ndir = (by<y) ? up : down;
5747 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5748 if(canmove(ndir,special,false))
5749 {
5750 dir=ndir;
5751 return;
5752 }
5753 }
5754
5755 ndir = (bx<x) ? left : right;
5756 if (grumble < 0 || (itemsbuf[((weapon*)Lwpns.spr(i))->parentitem].flags & ITEM_FLAG1)) ndir = oppositeDir[ndir];
5757 if(canmove(ndir,special,false))
5758 {
5759 dir=ndir;
5760 return;
5761 }
5762 }
5763 }
5764 47758 }
5765
5766
2/2
✓ Branch 0 taken 209238 times.
✓ Branch 1 taken 96950 times.
306188 if((zc_oldrand()&255)<abs(newhoming))
5767 {
5768 96950 ndir = lined_up(8,false);
5769
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 96950 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
96950 if (newhoming < 0 && ndir >= 0) ndir = oppositeDir[ndir];
5770
4/4
✓ Branch 0 taken 25542 times.
✓ Branch 1 taken 71408 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 22186 times.
96950 if(ndir>=0 && canmove(ndir,special,false))
5771 {
5772 22186 dir=ndir;
5773 22186 return;
5774 }
5775 74764 }
5776
5777 284002 int32_t i=0;
5778
5779
2/2
✓ Branch 0 taken 1257 times.
✓ Branch 1 taken 634621 times.
635878 for(; i<32; i++)
5780 {
5781 634621 int32_t r=zc_oldrand();
5782
5783
2/2
✓ Branch 0 taken 194900 times.
✓ Branch 1 taken 439721 times.
634621 if((r&15)<newrate)
5784 194900 ndir=(r>>4)&3;
5785 else
5786 439721 ndir=dir;
5787
5788
2/2
✓ Branch 0 taken 351876 times.
✓ Branch 1 taken 282745 times.
634621 if(canmove(ndir,special,false))
5789 282745 break;
5790 351876 }
5791
5792
2/2
✓ Branch 0 taken 282745 times.
✓ Branch 1 taken 1257 times.
284431 if(i==32)
5793 {
5794
2/2
✓ Branch 0 taken 3570 times.
✓ Branch 1 taken 429 times.
3999 for(ndir=0; ndir<4; ndir++)
5795 {
5796
2/2
✓ Branch 0 taken 2742 times.
✓ Branch 1 taken 828 times.
3570 if(canmove(ndir,special,false))
5797 828 goto ok;
5798 2742 }
5799
5800
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 369 times.
429 ndir = (isSideViewGravity()) ? (zc_oldrand()&1 ? left : right) : -1; // Sideview enemies get trapped if their dir becomes -1
5801 //...Isn't that the point? I'm not sure I understand. Certainly beats phasing through walls... -Dimi
5802 429 }
5803
5804 ok:
5805 284002 dir = ndir;
5806 306188 }
5807
5808 1092 void enemy::newdir()
5809 {
5810 1092 newdir(4,0,spw_none);
5811 1092 }
5812
5813 zfix enemy::distance_left()
5814 {
5815 int32_t a2=x.getInt();
5816 int32_t b2=y.getInt();
5817
5818 switch(dir)
5819 {
5820 case up:
5821 return (zfix)(b2&0xF);
5822
5823 case down:
5824 return (zfix)(16-(b2&0xF));
5825
5826 case left:
5827 return (zfix)(a2&0xF);
5828
5829 case right:
5830 return (zfix)(16-(a2&0xF));
5831 }
5832
5833 return (zfix)0;
5834 }
5835
5836 // keeps walking around
5837 226860 void enemy::constant_walk(int32_t newrate,int32_t newhoming,int32_t special)
5838 {
5839
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226860 times.
226860 if(slide())
5840 return;
5841
5842
8/12
✓ Branch 0 taken 224557 times.
✓ Branch 1 taken 2303 times.
✓ Branch 2 taken 224557 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 222559 times.
✓ Branch 5 taken 1998 times.
✓ Branch 6 taken 222559 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 222559 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 222559 times.
226860 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock )
5843 4301 return;
5844
5845
2/2
✓ Branch 0 taken 15372 times.
✓ Branch 1 taken 207187 times.
222559 if(clk3<=0)
5846 {
5847 15372 fix_coords(true);
5848 15372 newdir(newrate,newhoming,special);
5849
5850
1/2
✓ Branch 0 taken 15372 times.
✗ Branch 1 not taken.
15372 if(step==0)
5851 clk3=0;
5852 else
5853 15372 clk3=int32_t(16.0/step);
5854 15372 }
5855
2/2
✓ Branch 0 taken 207166 times.
✓ Branch 1 taken 21 times.
207187 else if(scored)
5856 {
5857 21 dir^=1;
5858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5859 else clk3=32767;
5860 21 }
5861
5862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 222559 times.
222559 if (step != 0) --clk3;
5863 222559 move(step);
5864 226860 }
5865
5866 void enemy::constant_walk()
5867 {
5868 constant_walk(4,0,spw_none);
5869 }
5870
5871 18230 int32_t enemy::pos(int32_t newx,int32_t newy)
5872 {
5873 18230 return (newy<<8)+newx;
5874 }
5875
5876 // for variable step rates
5877 234267 void enemy::variable_walk(int32_t newrate,int32_t newhoming,int32_t special)
5878 {
5879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
234267 if(slide())
5880 return;
5881
5882
10/14
✓ Branch 0 taken 234267 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 234267 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 228560 times.
✓ Branch 5 taken 5707 times.
✓ Branch 6 taken 221271 times.
✓ Branch 7 taken 7289 times.
✓ Branch 8 taken 200047 times.
✓ Branch 9 taken 21224 times.
✓ Branch 10 taken 200047 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 200047 times.
✗ Branch 13 not taken.
234267 if(clk<0 || dying || stunclk || watch || step == 0 || ceiling || frozenclock )
5883 34220 return;
5884
5885 200047 zfix dx = (zfix)0;
5886 200047 zfix dy = (zfix)0;
5887
5888
5/9
✓ Branch 0 taken 43624 times.
✓ Branch 1 taken 44366 times.
✓ Branch 2 taken 53763 times.
✓ Branch 3 taken 56539 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1755 times.
200047 switch(dir)
5889 {
5890 case 8:
5891 case up:
5892 43624 dy-=step;
5893 43624 break;
5894
5895 case 12:
5896 case down:
5897 44366 dy+=step;
5898 44366 break;
5899
5900 case 14:
5901 case left:
5902 53763 dx-=step;
5903 53763 break;
5904
5905 case 10:
5906 case right:
5907 56539 dx+=step;
5908 56539 break;
5909
5910 case 15:
5911 case l_up:
5912 dx-=step;
5913 dy-=step;
5914 break;
5915
5916 case 9:
5917 case r_up:
5918 dx+=step;
5919 dy-=step;
5920 break;
5921
5922 case 13:
5923 case l_down:
5924 dx-=step;
5925 dy+=step;
5926 break;
5927
5928 case 11:
5929 case r_down:
5930 dx+=step;
5931 dy+=step;
5932 break;
5933 }
5934
5935
8/8
✓ Branch 0 taken 95284 times.
✓ Branch 1 taken 104763 times.
✓ Branch 2 taken 12002 times.
✓ Branch 3 taken 83282 times.
✓ Branch 4 taken 5443 times.
✓ Branch 5 taken 6559 times.
✓ Branch 6 taken 193819 times.
✓ Branch 7 taken 6228 times.
200047 if(((int32_t(x)&15)==0 && (int32_t(y)&15)==0 && clk3!=pos(x,y)) ||
5936 194604 m_walkflag(int32_t(x+dx),int32_t(y+dy), spw_halfstep, dir))
5937 {
5938 6228 fix_coords();
5939 6228 newdir(newrate,newhoming,special);
5940 6228 clk3=pos(x,y);
5941 6228 }
5942
5943 200047 move(step);
5944 234267 }
5945
5946 // pauses for a while after it makes a complete move (to a new square)
5947 7485806 void enemy::halting_walk(int32_t newrate,int32_t newhoming,int32_t special,int32_t newhrate, int32_t haltcnt)
5948 {
5949
4/4
✓ Branch 0 taken 41807 times.
✓ Branch 1 taken 7443999 times.
✓ Branch 2 taken 33602 times.
✓ Branch 3 taken 8205 times.
7485806 if(sclk && clk2)
5950 {
5951 8205 clk3=0;
5952 8205 }
5953
5954
11/14
✓ Branch 0 taken 7448916 times.
✓ Branch 1 taken 36890 times.
✓ Branch 2 taken 7448916 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7448916 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7146105 times.
✓ Branch 7 taken 302811 times.
✓ Branch 8 taken 7019314 times.
✓ Branch 9 taken 126791 times.
✓ Branch 10 taken 7017542 times.
✓ Branch 11 taken 1772 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 7017542 times.
7485806 if(slide() || clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5955 {
5956 468264 return;
5957 }
5958
5959
2/2
✓ Branch 0 taken 1420795 times.
✓ Branch 1 taken 5596747 times.
7017542 if(clk2>0)
5960 {
5961 1420795 --clk2;
5962 1420795 return;
5963 }
5964
5965
2/2
✓ Branch 0 taken 243580 times.
✓ Branch 1 taken 5353167 times.
5596747 if(clk3<=0)
5966 {
5967 243580 fix_coords(true);
5968 243580 newdir(newrate,newhoming,special);
5969 243580 clk3=int32_t(16.0/step);
5970
2/2
✓ Branch 0 taken 243520 times.
✓ Branch 1 taken 60 times.
243580 if (step == 0) clk3 = 32767; //It used to return this in 2.53 and I'm unsure why; I'm guessing dividing by 0 gave max int? Either way, can't be 0 here or scripts break.
5971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243580 times.
243580 if(clk2<0)
5972 {
5973 clk2=0;
5974 }
5975
2/2
✓ Branch 0 taken 35125 times.
✓ Branch 1 taken 208455 times.
243580 else if((zc_oldrand()&15)<newhrate)
5976 {
5977 35125 clk2=haltcnt;
5978 35125 return;
5979 }
5980 208455 }
5981
2/2
✓ Branch 0 taken 5351685 times.
✓ Branch 1 taken 1482 times.
5353167 else if(scored)
5982 {
5983 1482 dir^=1;
5984
5985
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1481 times.
1482 if (step != 0) clk3=int32_t(16.0/step)-clk3;
5986 1 else clk3=32767;
5987 1482 }
5988
5989
2/2
✓ Branch 0 taken 37087 times.
✓ Branch 1 taken 5524535 times.
5561622 if (step != 0) --clk3;
5990 5561622 move(step);
5991 7485806 }
5992
5993 // 8-directional movement, aligns to 8 pixels
5994 void enemy::constant_walk_8(int32_t newrate,int32_t newhoming,int32_t special)
5995 {
5996 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
5997 return;
5998
5999 if(clk3<=0)
6000 {
6001 newdir_8(newrate,newhoming,special);
6002 clk3=int32_t(8.0/step);
6003 if (step == 0) clk3 = 32767;
6004 }
6005
6006 if (step != 0) --clk3;
6007 move(step);
6008 }
6009 // 8-directional movement, aligns to 8 pixels
6010 84876 void enemy::constant_walk_8_old(int32_t newrate,int32_t newhoming,int32_t special)
6011 {
6012
6/12
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 84876 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 84876 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 84876 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 84876 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 84876 times.
84876 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6013 return;
6014
6015
2/2
✓ Branch 0 taken 78734 times.
✓ Branch 1 taken 6142 times.
84876 if(clk3<=0)
6016 {
6017 6142 newdir_8(newrate,newhoming,special);
6018 6142 clk3=int32_t(8.0/step);
6019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6142 times.
6142 if (step == 0) clk3 = 32767;
6020 6142 }
6021
6022
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if (step != 0) --clk3;
6023 84876 move(step);
6024 84876 }
6025
6026 void enemy::halting_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t newhrate, int32_t haltcnt)
6027 {
6028 if(clk<0 || dying || stunclk || watch || frozenclock)
6029 return;
6030
6031 if(!canmove(dir,step,special,false))
6032 clk3=0;
6033
6034 if(clk2>0)
6035 {
6036 --clk2;
6037 return;
6038 }
6039
6040 if(clk3<=0)
6041 {
6042 newdir_8(newrate,newhoming,special);
6043 clk3=newclk;
6044
6045 if(clk2<0)
6046 {
6047 clk2=0;
6048 }
6049 else if((zc_oldrand()&15)<newhrate)
6050 {
6051 newdir_8(newrate,newhoming,special);
6052 clk2=haltcnt;
6053 return;
6054 }
6055 }
6056
6057 --clk3;
6058 move(step);
6059 }
6060
6061 // 8-directional movement, no alignment
6062 2513985 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special)
6063 {
6064
9/12
✓ Branch 0 taken 2408462 times.
✓ Branch 1 taken 105523 times.
✓ Branch 2 taken 2408462 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2386969 times.
✓ Branch 5 taken 21493 times.
✓ Branch 6 taken 2377143 times.
✓ Branch 7 taken 9826 times.
✓ Branch 8 taken 2377143 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 2377143 times.
2513985 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6065 136842 return;
6066
6067
2/2
✓ Branch 0 taken 2360249 times.
✓ Branch 1 taken 16894 times.
2377143 if(!canmove(dir,step,special,false))
6068 16894 clk3=0;
6069
6070
2/2
✓ Branch 0 taken 2075350 times.
✓ Branch 1 taken 301793 times.
2377143 if(clk3<=0)
6071 {
6072 301793 newdir_8(newrate,newhoming,special);
6073 301793 clk3=newclk;
6074 301793 }
6075
6076 2377143 --clk3;
6077 2377143 move(step);
6078 2513985 }
6079
6080 // same as above but with variable enemy size
6081 52535 void enemy::variable_walk_8(int32_t newrate,int32_t newhoming, int32_t newclk,int32_t special,int32_t dx1,int32_t dy1,int32_t dx2,int32_t dy2)
6082 {
6083
8/12
✓ Branch 0 taken 51768 times.
✓ Branch 1 taken 767 times.
✓ Branch 2 taken 51768 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 51768 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 51717 times.
✓ Branch 7 taken 51 times.
✓ Branch 8 taken 51717 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 51717 times.
52535 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
6084 818 return;
6085
6086
2/2
✓ Branch 0 taken 51200 times.
✓ Branch 1 taken 517 times.
51717 if(!canmove(dir,step,special,dx1,dy1,dx2,dy2,false))
6087 517 clk3=0;
6088
6089
2/2
✓ Branch 0 taken 48239 times.
✓ Branch 1 taken 3478 times.
51717 if(clk3<=0)
6090 {
6091 3478 newdir_8(newrate,newhoming,special,dx1,dy1,dx2,dy2);
6092 3478 clk3=newclk;
6093 3478 }
6094
6095 51717 --clk3;
6096 51717 move(step);
6097 52535 }
6098
6099 // the variable speed floater movement
6100 // ms is max speed
6101 // ss is step speed
6102 // s is step count
6103 // p is pause count
6104 // g is graduality :)
6105 //floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
6106 2107695 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
6107 {
6108 2107695 ++clk2;
6109 2107695 byte over_pit = overpit(this);
6110
6111
4/4
✓ Branch 0 taken 424954 times.
✓ Branch 1 taken 1682741 times.
✓ Branch 2 taken 424687 times.
✓ Branch 3 taken 267 times.
2107695 if(dmisc1 && over_pit) p = 0;
6112
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 36911 times.
✓ Branch 2 taken 849849 times.
✓ Branch 3 taken 1135402 times.
✓ Branch 4 taken 85533 times.
2107695 switch(movestatus)
6113 {
6114 //! This needs a case 4 (landing)....if we want to halt, we move to case 4, and
6115 //! if the conditions prevent it, we jump back to case 2.
6116 case 0: // paused
6117
2/2
✓ Branch 0 taken 36222 times.
✓ Branch 1 taken 689 times.
36911 if(clk2>=p)
6118 {
6119 689 movestatus=1;
6120 689 clk2=0;
6121 689 }
6122
6123 36911 break;
6124
6125 case 1: // speeding up
6126
1/2
✓ Branch 0 taken 849849 times.
✗ Branch 1 not taken.
849849 if (s >= 0)
6127 {
6128
2/2
✓ Branch 0 taken 844313 times.
✓ Branch 1 taken 5536 times.
849849 if(clk2<g*s)
6129 {
6130
2/2
✓ Branch 0 taken 790189 times.
✓ Branch 1 taken 54124 times.
844313 if(!((clk2-1)%g))
6131 54124 step+=ss;
6132 844313 }
6133 else
6134 {
6135 5536 movestatus=2;
6136 5536 clk2=0;
6137 }
6138 849849 }
6139 else
6140 {
6141 if(step < ms)
6142 {
6143 if(!((clk2-1)%g))
6144 {
6145 step+=ss;
6146 if (step >= ms) step = ms;
6147 }
6148 }
6149 else
6150 {
6151 step = ms;
6152 movestatus=2;
6153 clk2=0;
6154 }
6155 }
6156
6157 849849 break;
6158
6159 case 2: // normal
6160 1135402 step=ms;
6161
6162
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1135402 times.
✓ Branch 2 taken 237381 times.
✓ Branch 3 taken 898021 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 898021 times.
✓ Branch 6 taken 896841 times.
✓ Branch 7 taken 1180 times.
1135402 if(clk2>(dmisc15>0?dmisc15:48) && !(zc_oldrand()%(dmisc14>0?dmisc14:768)))
6163 {
6164
1/2
✓ Branch 0 taken 1180 times.
✗ Branch 1 not taken.
1180 if (s >= 0) step=ss*s;
6165 else step=ms;
6166 1180 movestatus=3;
6167 1180 clk2=0;
6168 1180 }
6169
6170 1135402 break;
6171
6172 case 3: // slowing down
6173
1/2
✓ Branch 0 taken 85533 times.
✗ Branch 1 not taken.
85533 if (s >= 0)
6174 {
6175
2/2
✓ Branch 0 taken 84707 times.
✓ Branch 1 taken 826 times.
85533 if(clk2<=g*s)
6176 {
6177 { //don't slow down over pits
6178
6179
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84695 times.
84707 if(over_pit)
6180 {
6181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(dmisc1)
6182 {
6183 step=ms;
6184 }
6185 12 }
6186 else //can slow down
6187 {
6188
4/4
✓ Branch 0 taken 5242 times.
✓ Branch 1 taken 79453 times.
✓ Branch 2 taken 4970 times.
✓ Branch 3 taken 272 times.
84695 if(!(clk2%g) && !dmisc1)
6189 4970 step-=ss;
6190 }
6191 }
6192
6193
6194 84707 }
6195 else
6196 {
6197 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6198 //this doesn't help keese, as they have a z of 0.
6199 //they always nee to run this check.
6200 {
6201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 826 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
826 if(over_pit &&!dmisc1)
6202 {
6203 --clk2; //if over a pit, don't land, and revert clock change
6204 }
6205 else //can land safely
6206 {
6207 826 movestatus=0;
6208
3/4
✓ Branch 0 taken 468 times.
✓ Branch 1 taken 358 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 468 times.
826 if(dmisc1&&!over_pit)
6209 468 step=0;
6210 826 clk2=0;
6211 }
6212 }
6213
6214 }
6215 85533 }
6216 else
6217 {
6218 if(step > 0)
6219 {
6220 if(over_pit)
6221 {
6222 if(dmisc1)
6223 {
6224 step=ms;
6225 }
6226 }
6227 else //can slow down
6228 {
6229 if(!(clk2%g))
6230 step-=ss;
6231 }
6232 }
6233 else
6234 {
6235 //if((moveflags&FLAG_CAN_PITFALL)) //don't check pits if the enemy ignores them
6236 //this doesn't help keese, as they have a z of 0.
6237 //they always nee to run this check.
6238 if(over_pit)
6239 {
6240 step+=ss; //if over a pit, don't land, and revert clock change
6241 }
6242 else //can land safely
6243 {
6244 movestatus=0;
6245 step=0;
6246 clk2=0;
6247 }
6248 }
6249 }
6250
6251 85533 break;
6252 }
6253
6254
2/2
✓ Branch 0 taken 1139758 times.
✓ Branch 1 taken 967937 times.
2107695 variable_walk_8(movestatus==2?newrate:0,homing,newclk,spw_floater);
6255 2107695 }
6256
6257 void enemy::floater_walk(int32_t newrate,int32_t newclk,zfix s)
6258 {
6259 floater_walk(newrate,newclk,s,(zfix)0.125,3,80,32);
6260 }
6261
6262 // Checks if enemy is lined up with Hero. If so, returns direction Hero is
6263 // at as compared to enemy. Returns -1 if not lined up. Range is inclusive.
6264 505599 int32_t enemy::lined_up(int32_t range, bool dir8)
6265 {
6266 505599 int32_t lx = Hero.getX();
6267 505599 int32_t ly = Hero.getY();
6268
6269
2/2
✓ Branch 0 taken 19794 times.
✓ Branch 1 taken 485805 times.
505599 if(abs(lx-int32_t(x))<=range)
6270 {
6271
2/2
✓ Branch 0 taken 7913 times.
✓ Branch 1 taken 11881 times.
19794 if(ly<y)
6272 {
6273 7913 return up;
6274 }
6275
6276 11881 return down;
6277 }
6278
6279
2/2
✓ Branch 0 taken 23666 times.
✓ Branch 1 taken 462139 times.
485805 if(abs(ly-int32_t(y))<=range)
6280 {
6281
2/2
✓ Branch 0 taken 12185 times.
✓ Branch 1 taken 11481 times.
23666 if(lx<x)
6282 {
6283 12185 return left;
6284 }
6285
6286 11481 return right;
6287 }
6288
6289
2/2
✓ Branch 0 taken 94764 times.
✓ Branch 1 taken 367375 times.
462139 if(dir8)
6290 {
6291
2/2
✓ Branch 0 taken 130299 times.
✓ Branch 1 taken 237076 times.
367375 if(abs(lx-x)-abs(ly-y)<=range)
6292 //if(abs(lx-x)-abs(ly-y)<=range && abs(ly-y)-abs(lx-x)<=range) //Fix floating enemies not seeking hero. -Tamamo
6293 {
6294
2/2
✓ Branch 0 taken 55233 times.
✓ Branch 1 taken 75066 times.
130299 if(ly<y)
6295 {
6296
2/2
✓ Branch 0 taken 32006 times.
✓ Branch 1 taken 23227 times.
55233 if(lx<x)
6297 {
6298 32006 return l_up;
6299 }
6300 else
6301 {
6302 23227 return r_up;
6303 }
6304 }
6305 else
6306 {
6307
2/2
✓ Branch 0 taken 38204 times.
✓ Branch 1 taken 36862 times.
75066 if(lx<x)
6308 {
6309 36862 return l_down;
6310 }
6311 else
6312 {
6313 38204 return r_down;
6314 }
6315 }
6316 }
6317 237076 }
6318
6319 331840 return -1;
6320 505599 }
6321
6322 // returns true if Hero is within 'range' pixels of the enemy
6323 13988 bool enemy::HeroInRange(int32_t range)
6324 {
6325 13988 int32_t lx = Hero.getX();
6326 13988 int32_t ly = Hero.getY();
6327
2/2
✓ Branch 0 taken 11733 times.
✓ Branch 1 taken 2255 times.
13988 return abs(lx-int32_t(x))<=range && abs(ly-int32_t(y))<=range;
6328 }
6329
6330 // place the enemy in line with Hero (red wizzrobes)
6331 2334 void enemy::place_on_axis(bool floater, bool solid_ok)
6332 {
6333
6/6
✓ Branch 0 taken 241 times.
✓ Branch 1 taken 2093 times.
✓ Branch 2 taken 2129 times.
✓ Branch 3 taken 205 times.
✓ Branch 4 taken 241 times.
✓ Branch 5 taken 1888 times.
2334 int32_t lx=zc_min(zc_max(int32_t(Hero.getX())&0xF0,32),208);
6334
6/6
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 2216 times.
✓ Branch 2 taken 1980 times.
✓ Branch 3 taken 354 times.
✓ Branch 4 taken 118 times.
✓ Branch 5 taken 1862 times.
2334 int32_t ly=zc_min(zc_max(int32_t(Hero.getY())&0xF0,32),128);
6335 2334 int32_t pos2=zc_oldrand()%23;
6336 2334 int32_t tried=0;
6337 2334 bool last_resort,placed=false;
6338
6339
6340 2334 do
6341 {
6342
2/2
✓ Branch 0 taken 2419 times.
✓ Branch 1 taken 1712 times.
4131 if(pos2<14)
6343 {
6344 2419 x=(pos2<<4)+16;
6345 2419 y=ly;
6346 2419 }
6347 else
6348 {
6349 1712 x=lx;
6350 1712 y=((pos2-14)<<4)+16;
6351 }
6352
6353 // Don't commit to a last resort if position is out of bounds.
6354
6/6
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 163 times.
✓ Branch 2 taken 3808 times.
✓ Branch 3 taken 160 times.
✓ Branch 4 taken 127 times.
✓ Branch 5 taken 3681 times.
4131 last_resort= !(x<32 || y<32 || x>=224 || y>=144);
6355
6356
4/4
✓ Branch 0 taken 2148 times.
✓ Branch 1 taken 1983 times.
✓ Branch 2 taken 3739 times.
✓ Branch 3 taken 1591 times.
4131 if(abs(lx-int32_t(x))>16 || abs(ly-int32_t(y))>16)
6357 {
6358 // Red Wizzrobes should be able to appear on water, but not other
6359 // solid combos; however, they could appear on solid combos in 2.10,
6360 // and some quests depend on that.
6361
4/4
✓ Branch 0 taken 2140 times.
✓ Branch 1 taken 3582 times.
✓ Branch 2 taken 1248 times.
✓ Branch 3 taken 2334 times.
5722 if((solid_ok || !m_walkflag(x,y,floater ? spw_water : spw_door, dir))
6362 5722 && !flyerblocked(x,y,floater ? spw_floater : spw_door))
6363 2334 placed=true;
6364 5722 }
6365
6366
3/6
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1797 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4817 if(!placed && tried>=22 && last_resort)
6367 {
6368 placed=true;
6369 }
6370
6371 4817 ++tried;
6372 4817 pos2=(pos2+3)%23;
6373
2/2
✓ Branch 0 taken 1797 times.
✓ Branch 1 taken 3020 times.
4817 }
6374 4817 while(!placed);
6375
6376
2/2
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 854 times.
3020 if(y==ly)
6377 2166 dir=(x<lx)?right:left;
6378 else
6379 854 dir=(y<ly)?down:up;
6380
6381 3020 clk2=tried;
6382 3020 }
6383
6384 10524416 int32_t enemy::n_frame_n_dir(int32_t frames, int32_t ndir, int32_t f4)
6385 {
6386 10524416 int32_t t = o_tile;
6387 10524416 int32_t b = o_tile;
6388
6389 // Darknuts, but also Wizzrobes and Wallmasters
6390
3/4
✓ Branch 0 taken 3963465 times.
✓ Branch 1 taken 6178051 times.
✓ Branch 2 taken 382900 times.
✗ Branch 3 not taken.
10524416 switch(family)
6391 {
6392 case eeWALK:
6393
5/6
✓ Branch 0 taken 373692 times.
✓ Branch 1 taken 5804359 times.
✓ Branch 2 taken 264807 times.
✓ Branch 3 taken 108885 times.
✓ Branch 4 taken 264807 times.
✗ Branch 5 not taken.
6178051 if(dmisc9==e9tPOLSVOICE && clk2>=0 && do_animation)
6394 {
6395 264807 tile=s_tile;
6396 264807 t=s_tile;
6397 264807 b=s_tile;
6398 264807 }
6399
6400 6178051 break;
6401
6402 case eeTRAP:
6403
4/6
✓ Branch 0 taken 141238 times.
✓ Branch 1 taken 241662 times.
✓ Branch 2 taken 141238 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 141238 times.
382900 if(dummy_int[1] && guysbuf[id].flags2 & eneflag_trp2 && do_animation) // Just to make sure
6404 {
6405 141238 tile=s_tile;
6406 141238 t=s_tile;
6407 141238 b=s_tile;
6408 141238 }
6409
6410 382900 break;
6411
6412 case eeSPINTILE:
6413 if(misc>=96 && do_animation)
6414 {
6415 tile=o_tile+frames*ndir;
6416 t=tile;
6417 }
6418
6419 break;
6420 }
6421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10524416 times.
10524416 if ( do_animation )
6422 {
6423
4/6
✓ Branch 0 taken 163042 times.
✓ Branch 1 taken 10361374 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 266817 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 10094557 times.
10524416 if(ndir!=0) switch(frames)
6424 {
6425 case 2:
6426 266817 tiledir_small(dir,ndir==4);
6427 266817 break;
6428
6429 case 3:
6430 tiledir_three(dir);
6431 break;
6432
6433 case 4:
6434 10094557 tiledir(dir,ndir==4);
6435 10094557 break;
6436 10361374 }
6437
6438
2/2
✓ Branch 0 taken 6178051 times.
✓ Branch 1 taken 4346365 times.
10524416 if(family==eeWALK)
6439
6/6
✓ Branch 0 taken 6167527 times.
✓ Branch 1 taken 10524 times.
✓ Branch 2 taken 4638452 times.
✓ Branch 3 taken 1539599 times.
✓ Branch 4 taken 1537069 times.
✓ Branch 5 taken 2530 times.
6178051 tile=zc_min(tile+f4, t+frames*(zc_max(dir, 0)+1)-1);
6440 else
6441 4346365 tile+=f4;
6442 10524416 }
6443 10524416 return b;
6444 }
6445
6446 void enemy::tiledir_three(int32_t ndir)
6447 {
6448 if ( !do_animation ) return;
6449 flip=0;
6450
6451 switch(ndir)
6452 {
6453 case right:
6454 tile+=3;
6455 [[fallthrough]];
6456
6457 case left:
6458 tile+=3;
6459 [[fallthrough]];
6460
6461 case down:
6462 tile+=3;
6463 [[fallthrough]];
6464
6465 case up:
6466 break;
6467 }
6468 }
6469
6470 266817 void enemy::tiledir_small(int32_t ndir, bool fourdir)
6471 {
6472
1/2
✓ Branch 0 taken 266817 times.
✗ Branch 1 not taken.
266817 if ( !do_animation ) return;
6473 266817 flip=0;
6474
6475
8/9
✓ Branch 0 taken 53728 times.
✓ Branch 1 taken 54633 times.
✓ Branch 2 taken 67625 times.
✓ Branch 3 taken 71117 times.
✓ Branch 4 taken 5706 times.
✓ Branch 5 taken 5154 times.
✓ Branch 6 taken 4872 times.
✓ Branch 7 taken 3982 times.
✗ Branch 8 not taken.
266817 switch(ndir)
6476 {
6477 case 8:
6478 case up:
6479 53728 break;
6480
6481 case 12:
6482 case down:
6483 54633 tile+=2;
6484 54633 break;
6485
6486 case 14:
6487 case left:
6488 67625 tile+=4;
6489 67625 break;
6490
6491 case 10:
6492 case right:
6493 71117 tile+=6;
6494 71117 break;
6495
6496 case 9:
6497 case r_up:
6498
1/2
✓ Branch 0 taken 5706 times.
✗ Branch 1 not taken.
5706 if(fourdir)
6499 5706 break;
6500
6501 tile+=10;
6502 break;
6503
6504 case 11:
6505 case r_down:
6506
1/2
✓ Branch 0 taken 5154 times.
✗ Branch 1 not taken.
5154 if(fourdir)
6507 5154 tile+=2;
6508 else
6509 tile+=14;
6510
6511 5154 break;
6512
6513 case 13:
6514 case l_down:
6515
1/2
✓ Branch 0 taken 4872 times.
✗ Branch 1 not taken.
4872 if(fourdir)
6516 4872 tile+=2;
6517 else
6518 tile+=12;
6519
6520 4872 break;
6521
6522 case 15:
6523 case l_up:
6524
1/2
✓ Branch 0 taken 3982 times.
✗ Branch 1 not taken.
3982 if(fourdir)
6525 3982 break;
6526
6527 tile+=8;
6528 break;
6529
6530 default:
6531 //dir=(zc_oldrand()*100)%8;
6532 //tiledir_small(dir);
6533 // flip=zc_oldrand()&3;
6534 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6535 break;
6536 }
6537 266817 }
6538
6539 11660468 void enemy::tiledir(int32_t ndir, bool fourdir)
6540 {
6541
1/2
✓ Branch 0 taken 11660468 times.
✗ Branch 1 not taken.
11660468 if ( !do_animation ) return;
6542 11660468 flip=0;
6543
6544
9/9
✓ Branch 0 taken 2359939 times.
✓ Branch 1 taken 2044242 times.
✓ Branch 2 taken 2781916 times.
✓ Branch 3 taken 2670926 times.
✓ Branch 4 taken 406885 times.
✓ Branch 5 taken 486841 times.
✓ Branch 6 taken 474500 times.
✓ Branch 7 taken 419015 times.
✓ Branch 8 taken 16204 times.
11660468 switch(ndir)
6545 {
6546 case 8:
6547 case up:
6548 2359939 break;
6549
6550 case 12:
6551 case down:
6552 2044242 tile+=4;
6553 2044242 break;
6554
6555 case 14:
6556 case left:
6557 2781916 tile+=8;
6558 2781916 break;
6559
6560 case 10:
6561 case right:
6562 2670926 tile+=12;
6563 2670926 break;
6564
6565 case 9:
6566 case r_up:
6567
2/2
✓ Branch 0 taken 57693 times.
✓ Branch 1 taken 349192 times.
406885 if(fourdir)
6568 57693 break;
6569 else
6570 349192 tile+=24;
6571
6572 349192 break;
6573
6574 case 11:
6575 case r_down:
6576
2/2
✓ Branch 0 taken 63504 times.
✓ Branch 1 taken 423337 times.
486841 if(fourdir)
6577 63504 tile+=4;
6578 else
6579 423337 tile+=32;
6580
6581 486841 break;
6582
6583 case 13:
6584 case l_down:
6585
2/2
✓ Branch 0 taken 66073 times.
✓ Branch 1 taken 408427 times.
474500 if(fourdir)
6586 66073 tile+=4;
6587 else
6588 408427 tile+=28;
6589
6590 474500 break;
6591
6592 case 15:
6593 case l_up:
6594
2/2
✓ Branch 0 taken 50160 times.
✓ Branch 1 taken 368855 times.
419015 if(fourdir)
6595 50160 break;
6596 else
6597 368855 tile+=20;
6598
6599 368855 break;
6600
6601 default:
6602 //dir=(zc_oldrand()*100)%8;
6603 //tiledir(dir);
6604 // flip=zc_oldrand()&3;
6605 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6606 16204 break;
6607 }
6608 11660468 }
6609
6610 3868 void enemy::tiledir_big(int32_t ndir, bool fourdir)
6611 {
6612
1/2
✓ Branch 0 taken 3868 times.
✗ Branch 1 not taken.
3868 if ( !do_animation ) return;
6613 3868 flip=0;
6614
6615
7/9
✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 195 times.
✓ Branch 3 taken 179 times.
✓ Branch 4 taken 306 times.
✓ Branch 5 taken 1235 times.
✓ Branch 6 taken 1324 times.
✓ Branch 7 taken 332 times.
✗ Branch 8 not taken.
3868 switch(ndir)
6616 {
6617 case 8:
6618 case up:
6619 297 break;
6620
6621 case 12:
6622 case down:
6623 tile+=8;
6624 break;
6625
6626 case 14:
6627 case left:
6628 195 tile+=40;
6629 195 break;
6630
6631 case 10:
6632 case right:
6633 179 tile+=48;
6634 179 break;
6635
6636 case 9:
6637 case r_up:
6638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
306 if(fourdir)
6639 break;
6640
6641 306 tile+=88;
6642 306 break;
6643
6644 case 11:
6645 case r_down:
6646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1235 times.
1235 if(fourdir)
6647 tile+=8;
6648 else
6649 1235 tile+=128;
6650
6651 1235 break;
6652
6653 case 13:
6654 case l_down:
6655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1324 times.
1324 if(fourdir)
6656 tile+=8;
6657 else
6658 1324 tile+=120;
6659
6660 1324 break;
6661
6662 case 15:
6663 case l_up:
6664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
332 if(fourdir)
6665 break;
6666
6667 332 tile+=80;
6668 332 break;
6669
6670 default:
6671 //dir=(zc_oldrand()*100)%8;
6672 //tiledir_big(dir);
6673 // flip=zc_oldrand()&3;
6674 // tile=(zc_oldrand()*100000)%NEWMAXTILES;
6675 break;
6676 }
6677 3868 }
6678
6679 22905054 void enemy::update_enemy_frame()
6680 {
6681
3/4
✓ Branch 0 taken 22904912 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22904912 times.
22905054 if(fallclk||drownclk) return;
6682
1/2
✓ Branch 0 taken 22904912 times.
✗ Branch 1 not taken.
22904912 if (!do_animation)
6683 return;
6684
6685
3/4
✓ Branch 0 taken 153758 times.
✓ Branch 1 taken 22751154 times.
✓ Branch 2 taken 153758 times.
✗ Branch 3 not taken.
22904912 if (get_qr(qr_OLD_TILE_INITIALIZATION) || tile == 0) tile = o_tile; //tile was initialized here before. It needs to be initialized here as well.
6686
6687
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
22904912 if(get_qr(qr_ANONE_NOANIM)
6688
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22904912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
22904912 && anim == aNONE && family != eeGUY)
6689 return;
6690
2/2
✓ Branch 0 taken 45769 times.
✓ Branch 1 taken 22859143 times.
22904912 int32_t newfrate = zc_max(frate,4);
6691 22904912 int32_t f4=abs(clk/(newfrate/4)); // casts clk to [0,1,2,3]
6692 22904912 int32_t f2=abs(clk/(newfrate/2)); // casts clk to [0,1]
6693
2/2
✓ Branch 0 taken 15606509 times.
✓ Branch 1 taken 7298403 times.
22904912 int32_t fx = get_qr(qr_NEWENEMYTILES) ? f4 : f2;
6694 22904912 tile = o_tile;
6695 22904912 int32_t basetile = o_tile;
6696 22904912 int32_t tilerows = 1; // How many rows of tiles? The Extend code needs to know.
6697 22904912 bool ignore_extend = false;
6698
34/40
✓ Branch 0 taken 164903 times.
✓ Branch 1 taken 5459 times.
✓ Branch 2 taken 38520 times.
✓ Branch 3 taken 1313148 times.
✓ Branch 4 taken 216057 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 89141 times.
✓ Branch 7 taken 233641 times.
✓ Branch 8 taken 128056 times.
✓ Branch 9 taken 3868 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 2773771 times.
✓ Branch 12 taken 41139 times.
✓ Branch 13 taken 50626 times.
✓ Branch 14 taken 818 times.
✓ Branch 15 taken 353574 times.
✓ Branch 16 taken 622431 times.
✓ Branch 17 taken 163042 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 98223 times.
✓ Branch 20 taken 157529 times.
✓ Branch 21 taken 428287 times.
✓ Branch 22 taken 1050207 times.
✓ Branch 23 taken 934304 times.
✗ Branch 24 not taken.
✓ Branch 25 taken 266817 times.
✓ Branch 26 taken 2408805 times.
✓ Branch 27 taken 3857795 times.
✗ Branch 28 not taken.
✓ Branch 29 taken 399313 times.
✓ Branch 30 taken 912736 times.
✓ Branch 31 taken 614651 times.
✓ Branch 32 taken 161932 times.
✓ Branch 33 taken 1317852 times.
✓ Branch 34 taken 74670 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 3483844 times.
✓ Branch 37 taken 281552 times.
✓ Branch 38 taken 219227 times.
✓ Branch 39 taken 38974 times.
22904912 switch(anim)
6699 {
6700
6701 case aDONGO:
6702 {
6703 41139 int32_t fr = stunclk>0 ? 16 : 8;
6704
6705
6/6
✓ Branch 0 taken 39717 times.
✓ Branch 1 taken 1422 times.
✓ Branch 2 taken 4800 times.
✓ Branch 3 taken 34917 times.
✓ Branch 4 taken 1600 times.
✓ Branch 5 taken 3200 times.
41139 if(!dying && clk2>0 && clk2<=64)
6706 {
6707 // bloated
6708
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✓ Branch 2 taken 448 times.
✓ Branch 3 taken 1152 times.
✓ Branch 4 taken 768 times.
3200 switch(dir)
6709 {
6710 case up:
6711 832 tile+=9;
6712 832 flip=0;
6713 832 xofs=0;
6714 832 dummy_int[1]=0; //no additional tiles
6715 832 break;
6716
6717 case down:
6718 448 tile+=7;
6719 448 flip=0;
6720 448 xofs=0;
6721 448 dummy_int[1]=0; //no additional tiles
6722 448 break;
6723
6724 case left:
6725 1152 flip=1;
6726 1152 tile+=4;
6727 1152 xofs=16;
6728 1152 dummy_int[1]=1; //second tile is next tile
6729 1152 break;
6730
6731 case right:
6732 768 flip=0;
6733 768 tile+=5;
6734 768 xofs=16;
6735 768 dummy_int[1]=-1; //second tile is previous tile
6736 768 break;
6737 }
6738 3200 }
6739
4/4
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 36517 times.
✓ Branch 2 taken 639 times.
✓ Branch 3 taken 783 times.
37939 else if(!dying || clk2>19)
6740 {
6741 // normal
6742
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 7974 times.
✓ Branch 2 taken 8400 times.
✓ Branch 3 taken 12214 times.
✓ Branch 4 taken 8568 times.
37156 switch(dir)
6743 {
6744 case up:
6745 7974 tile+=8;
6746 7974 flip=(clk&fr)?1:0;
6747 7974 xofs=0;
6748 7974 dummy_int[1]=0; //no additional tiles
6749 7974 break;
6750
6751 case down:
6752 8400 tile+=6;
6753 8400 flip=(clk&fr)?1:0;
6754 8400 xofs=0;
6755 8400 dummy_int[1]=0; //no additional tiles
6756 8400 break;
6757
6758 case left:
6759 12214 flip=1;
6760 12214 tile+=(clk&fr)?2:0;
6761 12214 xofs=16;
6762 12214 dummy_int[1]=1; //second tile is next tile
6763 12214 break;
6764
6765 case right:
6766 8568 flip=0;
6767 8568 tile+=(clk&fr)?3:1;
6768 8568 xofs=16;
6769 8568 dummy_int[1]=-1; //second tile is next tile
6770 8568 break;
6771 }
6772 37156 }
6773 }
6774 41139 break;
6775
6776 case aNEWDONGO:
6777 {
6778 50626 int32_t fr4=0;
6779
6780
6/6
✓ Branch 0 taken 48878 times.
✓ Branch 1 taken 1748 times.
✓ Branch 2 taken 3936 times.
✓ Branch 3 taken 44942 times.
✓ Branch 4 taken 1312 times.
✓ Branch 5 taken 2624 times.
50626 if(!dying && clk2>0 && clk2<=64)
6781 {
6782 // bloated
6783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2624 times.
2624 if(clk2>=0)
6784 {
6785 2624 fr4=3;
6786 2624 }
6787
6788
2/2
✓ Branch 0 taken 615 times.
✓ Branch 1 taken 2009 times.
2624 if(clk2>=16)
6789 {
6790 2009 fr4=2;
6791 2009 }
6792
6793
2/2
✓ Branch 0 taken 1271 times.
✓ Branch 1 taken 1353 times.
2624 if(clk2>=32)
6794 {
6795 1353 fr4=1;
6796 1353 }
6797
6798
2/2
✓ Branch 0 taken 1927 times.
✓ Branch 1 taken 697 times.
2624 if(clk2>=48)
6799 {
6800 697 fr4=0;
6801 697 }
6802
6803
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 704 times.
✓ Branch 4 taken 1088 times.
2624 switch(dir)
6804 {
6805 case up:
6806 256 xofs=0;
6807 256 tile+=8+fr4;
6808 256 dummy_int[1]=0; //no additional tiles
6809 256 break;
6810
6811 case down:
6812 576 xofs=0;
6813 576 tile+=12+fr4;
6814 576 dummy_int[1]=0; //no additional tiles
6815 576 break;
6816
6817 case left:
6818 704 tile+=29+(2*fr4);
6819 704 xofs=16;
6820 704 dummy_int[1]=-1; //second tile is previous tile
6821 704 break;
6822
6823 case right:
6824 1088 tile+=49+(2*fr4);
6825 1088 xofs=16;
6826 1088 dummy_int[1]=-1; //second tile is previous tile
6827 1088 break;
6828 }
6829 2624 }
6830
4/4
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 46254 times.
✓ Branch 2 taken 923 times.
✓ Branch 3 taken 825 times.
48002 else if(!dying || clk2>19)
6831 {
6832 // normal
6833
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 9019 times.
✓ Branch 2 taken 9429 times.
✓ Branch 3 taken 14024 times.
✓ Branch 4 taken 14705 times.
47177 switch(dir)
6834 {
6835 case up:
6836 9019 xofs=0;
6837 9019 tile+=((clk&12)>>2);
6838 9019 dummy_int[1]=0; //no additional tiles
6839 9019 break;
6840
6841 case down:
6842 9429 xofs=0;
6843 9429 tile+=4+((clk&12)>>2);
6844 9429 dummy_int[1]=0; //no additional tiles
6845 9429 break;
6846
6847 case left:
6848 14024 tile+=21+((clk&12)>>1);
6849 14024 xofs=16;
6850 14024 dummy_int[1]=-1; //second tile is previous tile
6851 14024 break;
6852
6853 case right:
6854 14705 flip=0;
6855 14705 tile+=41+((clk&12)>>1);
6856 14705 xofs=16;
6857 14705 dummy_int[1]=-1; //second tile is previous tile
6858 14705 break;
6859 }
6860 47177 }
6861 }
6862 50626 break;
6863
6864 case aDONGOBS:
6865 {
6866 818 int32_t fr4=0;
6867
6868
6/6
✓ Branch 0 taken 782 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 590 times.
✓ Branch 4 taken 64 times.
✓ Branch 5 taken 128 times.
818 if(!dying && clk2>0 && clk2<=64)
6869 {
6870 // bloated
6871
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(clk2>=0)
6872 {
6873 128 fr4=3;
6874 128 }
6875
6876
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 98 times.
128 if(clk2>=16)
6877 {
6878 98 fr4=2;
6879 98 }
6880
6881
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 66 times.
128 if(clk2>=32)
6882 {
6883 66 fr4=1;
6884 66 }
6885
6886
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 34 times.
128 if(clk2>=48)
6887 {
6888 34 fr4=0;
6889 34 }
6890
6891
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
128 switch(dir)
6892 {
6893 case up:
6894 tile+=28+fr4;
6895 yofs+=8;
6896 dummy_int[1]=-20; //second tile change
6897 dummy_int[2]=0; //new xofs change
6898 dummy_int[3]=-16; //new xofs change
6899 break;
6900
6901 case down:
6902 tile+=12+fr4;
6903 yofs-=8;
6904 dummy_int[1]=20; //second tile change
6905 dummy_int[2]=0; //new xofs change
6906 dummy_int[3]=16; //new xofs change
6907 break;
6908
6909 case left:
6910 128 tile+=49+(2*fr4);
6911 128 xofs+=8;
6912 128 dummy_int[1]=-1; //second tile change
6913 128 dummy_int[2]=-16; //new xofs change
6914 128 dummy_int[3]=0; //new xofs change
6915 128 break;
6916
6917 case right:
6918 tile+=69+(2*fr4);
6919 xofs+=8;
6920 dummy_int[1]=-1; //second tile change
6921 dummy_int[2]=-16; //new xofs change
6922 dummy_int[3]=0; //new xofs change
6923 break;
6924 }
6925 128 }
6926
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
690 else if(!dying || clk2>19)
6927 {
6928 // normal
6929
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 332 times.
✓ Branch 4 taken 97 times.
654 switch(dir)
6930 {
6931 case up:
6932 96 tile+=20+((clk&24)>>3);
6933 96 yofs+=8;
6934 96 dummy_int[1]=-20; //second tile change
6935 96 dummy_int[2]=0; //new xofs change
6936 96 dummy_int[3]=-16; //new xofs change
6937 96 break;
6938
6939 case down:
6940 129 tile+=4+((clk&24)>>3);
6941 129 yofs-=8;
6942 129 dummy_int[1]=20; //second tile change
6943 129 dummy_int[2]=0; //new xofs change
6944 129 dummy_int[3]=16; //new xofs change
6945 129 break;
6946
6947 case left:
6948 332 xofs=-8;
6949 332 tile+=40+((clk&24)>>2);
6950 332 dummy_int[1]=1; //second tile change
6951 332 dummy_int[2]=16; //new xofs change
6952 332 dummy_int[3]=0; //new xofs change
6953 332 break;
6954
6955 case right:
6956 97 tile+=60+((clk&24)>>2);
6957 97 xofs=-8;
6958 97 dummy_int[1]=1; //second tile change
6959 97 dummy_int[2]=16; //new xofs change
6960 97 dummy_int[3]=0; //new xofs change
6961 97 break;
6962 }
6963 654 }
6964 }
6965 818 break;
6966
6967 case aWIZZ:
6968 {
6969 // if(d->misc1)
6970
2/2
✓ Branch 0 taken 139048 times.
✓ Branch 1 taken 214526 times.
353574 if(dmisc1)
6971 {
6972
2/2
✓ Branch 0 taken 69275 times.
✓ Branch 1 taken 69773 times.
139048 if(clk&8)
6973 {
6974 69773 ++tile;
6975 69773 }
6976 139048 }
6977 else
6978 {
6979
2/2
✓ Branch 0 taken 107350 times.
✓ Branch 1 taken 107176 times.
214526 if(frame&4)
6980 {
6981 107176 ++tile;
6982 107176 }
6983 }
6984
6985
4/4
✓ Branch 0 taken 55328 times.
✓ Branch 1 taken 124116 times.
✓ Branch 2 taken 114795 times.
✓ Branch 3 taken 59335 times.
353574 switch(dir)
6986 {
6987 case 9:
6988 case 15:
6989 case up:
6990 55328 tile+=2;
6991 55328 break;
6992
6993 case down:
6994 59335 break;
6995
6996 case 13:
6997 case left:
6998 124116 flip=1;
6999 124116 break;
7000
7001 default:
7002 114795 flip=0;
7003 114795 break;
7004 }
7005 }
7006 353574 break;
7007
7008 case aNEWWIZZ:
7009 {
7010 622431 tiledir(dir,true);
7011
7012 // if(d->misc1) //walking wizzrobe
7013
2/2
✓ Branch 0 taken 330881 times.
✓ Branch 1 taken 291550 times.
622431 if(dmisc1) //walking wizzrobe
7014 {
7015
2/2
✓ Branch 0 taken 166270 times.
✓ Branch 1 taken 164611 times.
330881 if(clk&8)
7016 {
7017 164611 tile+=2;
7018 164611 }
7019
7020
2/2
✓ Branch 0 taken 165827 times.
✓ Branch 1 taken 165054 times.
330881 if(clk&4)
7021 {
7022 165054 tile+=1;
7023 165054 }
7024
7025
2/4
✓ Branch 0 taken 330881 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 330881 times.
330881 if(!(dummy_bool[1]||dummy_bool[2])) //should never be charging or firing for these wizzrobes
7026 {
7027
2/2
✓ Branch 0 taken 296297 times.
✓ Branch 1 taken 34584 times.
330881 if(dummy_int[1]>0)
7028 {
7029 34584 tile+=40;
7030 34584 }
7031 330881 }
7032 330881 }
7033 else
7034 {
7035
4/4
✓ Branch 0 taken 267218 times.
✓ Branch 1 taken 24332 times.
✓ Branch 2 taken 62854 times.
✓ Branch 3 taken 204364 times.
291550 if(dummy_bool[1]||dummy_bool[2])
7036 {
7037 87186 tile+=20;
7038
7039
2/2
✓ Branch 0 taken 24332 times.
✓ Branch 1 taken 62854 times.
87186 if(dummy_bool[2])
7040 {
7041 62854 tile+=20;
7042 62854 }
7043 87186 }
7044
7045 291550 tile+=((frame>>1)&3);
7046 }
7047 }
7048 622431 break;
7049
7050 case a3FRM:
7051 {
7052
2/2
✓ Branch 0 taken 38762 times.
✓ Branch 1 taken 124280 times.
163042 basetile = n_frame_n_dir(3, 0, (f4==3) ? 1 : f4);
7053 }
7054 163042 break;
7055
7056 case a3FRM4DIR:
7057 {
7058 basetile = n_frame_n_dir(3, 4, (f4==3) ? 1 : f4);
7059 }
7060 break;
7061
7062 case aVIRE:
7063 {
7064
2/2
✓ Branch 0 taken 76001 times.
✓ Branch 1 taken 22222 times.
98223 if(dir==up)
7065 {
7066 22222 tile+=2;
7067 22222 }
7068
7069 98223 tile+=fx;
7070 }
7071 98223 break;
7072
7073 case aROPE:
7074 {
7075 164903 tile+=(1-fx);
7076 164903 flip = dir==left ? 1:0;
7077 }
7078 164903 break;
7079
7080 case aZORA:
7081 {
7082 int32_t dl;
7083
7084
2/2
✓ Branch 0 taken 33018 times.
✓ Branch 1 taken 124511 times.
157529 if(clk<36)
7085 {
7086 33018 dl=clk+5;
7087 33018 goto waves2;
7088 }
7089
7090
2/2
✓ Branch 0 taken 58613 times.
✓ Branch 1 taken 65898 times.
124511 if(clk<36+66)
7091
2/2
✓ Branch 0 taken 33479 times.
✓ Branch 1 taken 25134 times.
58613 tile=(dir==up)?o_tile+1:o_tile;
7092 else
7093 {
7094 65898 dl=clk-36-66;
7095 waves2:
7096 98916 tile=((dl/11)&1)+s_tile;
7097 98916 basetile = s_tile;
7098 }
7099 }
7100 157529 break;
7101
7102 case aNEWZORA:
7103 {
7104 428287 f4=(clk/16)%4;
7105
7106 428287 tiledir(dir,true);
7107 int32_t dl;
7108
7109
4/4
✓ Branch 0 taken 304957 times.
✓ Branch 1 taken 123330 times.
✓ Branch 2 taken 159809 times.
✓ Branch 3 taken 145148 times.
428287 if((clk>35)&&(clk<36+67)) //surfaced
7110 {
7111
4/4
✓ Branch 0 taken 123977 times.
✓ Branch 1 taken 21171 times.
✓ Branch 2 taken 17680 times.
✓ Branch 3 taken 106297 times.
145148 if((clk>=(35+10))&&(clk<(38+56))) //mouth open
7112 {
7113 106297 tile+=80;
7114 106297 } //mouth closed
7115 else
7116 {
7117 38851 tile+=40;
7118 }
7119
7120 145148 tile+=f4;
7121 145148 }
7122 else
7123 {
7124
2/2
✓ Branch 0 taken 123330 times.
✓ Branch 1 taken 159809 times.
283139 if(clk<36)
7125 {
7126 123330 dl=clk+5;
7127 123330 }
7128 else
7129 {
7130 159809 dl=clk-36-66;
7131 }
7132
7133 283139 tile+=((dl/5)&3);
7134 }
7135 }
7136 428287 break;
7137
7138 case a4FRM4EYE:
7139 case a2FRM4EYE:
7140 case a4FRM8EYE:
7141 case a4FRM8EYEB: //big version
7142 case a4FRM4EYEB:
7143 {
7144 128056 tilerows = 2;
7145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakex = x + 8*(zc_max(1,txsz)-1);
7146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128056 times.
128056 int fakey = y + 8*(zc_max(1,tysz)-1);
7147 double _MSVC2022_tmp1, _MSVC2022_tmp2;
7148 128056 double ddir=atan2_MSVC2022_FIX(double(fakey-(Hero.y)),double(Hero.x-fakex));
7149 128056 int32_t lookat=zc_oldrand()&15;
7150
7151
4/4
✓ Branch 0 taken 40954 times.
✓ Branch 1 taken 87102 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 20770 times.
128056 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
7152 {
7153 20770 lookat=l_down;
7154 20770 }
7155
4/4
✓ Branch 0 taken 41196 times.
✓ Branch 1 taken 66090 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 21012 times.
107286 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
7156 {
7157 21012 lookat=down;
7158 21012 }
7159
4/4
✓ Branch 0 taken 33446 times.
✓ Branch 1 taken 52828 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 13262 times.
86274 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
7160 {
7161 13262 lookat=r_down;
7162 13262 }
7163
4/4
✓ Branch 0 taken 32038 times.
✓ Branch 1 taken 40974 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 11854 times.
73012 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
7164 {
7165 11854 lookat=right;
7166 11854 }
7167
4/4
✓ Branch 0 taken 25060 times.
✓ Branch 1 taken 36098 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 4876 times.
61158 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
7168 {
7169 4876 lookat=r_up;
7170 4876 }
7171
4/4
✓ Branch 0 taken 26018 times.
✓ Branch 1 taken 30264 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 5834 times.
56282 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
7172 {
7173 5834 lookat=up;
7174 5834 }
7175
4/4
✓ Branch 0 taken 30200 times.
✓ Branch 1 taken 20248 times.
✓ Branch 2 taken 20184 times.
✓ Branch 3 taken 10016 times.
50448 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
7176 {
7177 10016 lookat=l_up;
7178 10016 }
7179 else
7180 {
7181 40432 lookat=left;
7182 }
7183
7184 128056 int32_t dir2 = dir;
7185 128056 dir = lookat;
7186
3/6
✓ Branch 0 taken 128056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 128056 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128056 times.
128056 if (anim != a4FRM8EYEB && anim != a4FRM4EYEB) basetile = n_frame_n_dir(anim==a2FRM4EYE ? 2:4, anim==a4FRM8EYE ? 8 : 4, anim==a2FRM4EYE ? (f2&1):f4);
7187 else
7188 {
7189 tiledir_big(dir,(anim == a4FRM4EYEB));
7190 tile+=2*f4;
7191 ignore_extend = true;
7192 }
7193 128056 dir = dir2;
7194 }
7195 128056 break;
7196
7197 case aFLIP:
7198 {
7199 1050207 flip = f2&1;
7200 }
7201 1050207 break;
7202
7203 case a2FRM:
7204 {
7205 934304 tile += (1-f2);
7206 }
7207 934304 break;
7208
7209 case a2FRMB:
7210 {
7211 tile+= 2*(1-f2);
7212 ignore_extend = true;
7213 }
7214 break;
7215
7216 case a2FRM4DIR:
7217 {
7218 266817 basetile = n_frame_n_dir(2, 4, f2&1);
7219 }
7220 266817 break;
7221
7222 case a4FRM4DIRF:
7223 {
7224 2408805 basetile = n_frame_n_dir(4,4,f4);
7225
7226
2/2
✓ Branch 0 taken 1574669 times.
✓ Branch 1 taken 834136 times.
2408805 if(clk2>0) //stopped to fire
7227 {
7228 834136 tile+=20;
7229
7230
2/2
✓ Branch 0 taken 413682 times.
✓ Branch 1 taken 420454 times.
834136 if(clk2<17) //firing
7231 {
7232 420454 tile+=20;
7233 420454 }
7234 834136 }
7235 }
7236 2408805 break;
7237
7238 case a4FRM4DIR:
7239 {
7240 3857795 basetile = n_frame_n_dir(4,4,f4);
7241 }
7242 3857795 break;
7243
7244 case a4FRM8DIRF:
7245 {
7246 tilerows = 2;
7247 basetile = n_frame_n_dir(4,8,f4);
7248
7249 if(clk2>0) //stopped to fire
7250 {
7251 tile+=40;
7252
7253 if(clk2<17) //firing
7254 {
7255 tile+=40;
7256 }
7257 }
7258 }
7259 break;
7260
7261 case a4FRM8DIRB:
7262 case a4FRM8DIRFB:
7263 {
7264 3868 tilerows = 2;
7265 3868 tiledir_big(dir,false);
7266 3868 tile+=2*f4;
7267
3/4
✓ Branch 0 taken 3866 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 3866 times.
✗ Branch 3 not taken.
3868 if(clk2>0 && anim == a4FRM8DIRFB) //stopped to fire
7268 {
7269 tile+=80;
7270
7271 if(clk2<17) //firing
7272 {
7273 tile+=80;
7274 }
7275 }
7276 3868 ignore_extend = true;
7277 }
7278 3868 break;
7279
7280 case a4FRM4DIRB:
7281 case a4FRM4DIRFB:
7282 {
7283 tilerows = 2;
7284 tiledir_big(dir,true);
7285 tile+=2*f4;
7286 if(clk2>0 && anim == a4FRM4DIRFB) //stopped to fire
7287 {
7288 tile+=40;
7289
7290 if(clk2<17) //firing
7291 {
7292 tile+=40;
7293 }
7294 }
7295 ignore_extend = true;
7296 }
7297 break;
7298
7299 case aOCTO:
7300 {
7301
5/5
✓ Branch 0 taken 2913 times.
✓ Branch 1 taken 85458 times.
✓ Branch 2 taken 96229 times.
✓ Branch 3 taken 112826 times.
✓ Branch 4 taken 101887 times.
399313 switch(dir)
7302 {
7303 case up:
7304 85458 flip = 2;
7305 85458 break;
7306
7307 case down:
7308 96229 flip = 0;
7309 96229 break;
7310
7311 case left:
7312 112826 flip = 0;
7313 112826 tile += 2;
7314 112826 break;
7315
7316 case right:
7317 101887 flip = 1;
7318 101887 tile += 2;
7319 101887 break;
7320 }
7321
7322 399313 tile+=f2;
7323 }
7324 399313 break;
7325
7326 case aWALK:
7327 {
7328
5/5
✓ Branch 0 taken 4582 times.
✓ Branch 1 taken 187339 times.
✓ Branch 2 taken 207694 times.
✓ Branch 3 taken 256906 times.
✓ Branch 4 taken 256215 times.
912736 switch(dir)
7329 {
7330 case up:
7331 187339 tile+=3;
7332 187339 flip = f2;
7333 187339 break;
7334
7335 case down:
7336 207694 tile+=2;
7337 207694 flip = f2;
7338 207694 break;
7339
7340 case left:
7341 256906 flip=1;
7342 256906 tile += f2;
7343 256906 break;
7344
7345 case right:
7346 256215 flip=0;
7347 256215 tile += f2;
7348 256215 break;
7349 }
7350 }
7351 912736 break;
7352
7353 case aDWALK:
7354 {
7355
3/4
✓ Branch 0 taken 81208 times.
✓ Branch 1 taken 533443 times.
✓ Branch 2 taken 81208 times.
✗ Branch 3 not taken.
614651 if((get_qr(qr_BRKNSHLDTILES)) && (dummy_bool[1]==true))
7356 {
7357 tile=s_tile;
7358 basetile = s_tile;
7359 }
7360
7361
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129268 times.
✓ Branch 2 taken 133261 times.
✓ Branch 3 taken 177242 times.
✓ Branch 4 taken 174880 times.
614651 switch(dir)
7362 {
7363 case up:
7364 129268 tile+=2;
7365 129268 flip=f2;
7366 129268 break;
7367
7368 case down:
7369 133261 flip=0;
7370 133261 tile+=(1-f2);
7371 133261 break;
7372
7373 case left:
7374 177242 flip=1;
7375 177242 tile+=(3+f2);
7376 177242 break;
7377
7378 case right:
7379 174880 flip=0;
7380 174880 tile+=(3+f2);
7381 174880 break;
7382 }
7383 }
7384 614651 break;
7385
7386 case aTEK:
7387 {
7388
2/2
✓ Branch 0 taken 101376 times.
✓ Branch 1 taken 60556 times.
161932 if(misc==0)
7389 {
7390 60556 tile += f2;
7391 60556 }
7392
2/2
✓ Branch 0 taken 53958 times.
✓ Branch 1 taken 47418 times.
101376 else if(misc!=1)
7393 {
7394 47418 ++tile;
7395 47418 }
7396 }
7397 161932 break;
7398
7399 case aNEWTEK:
7400 {
7401
2/2
✓ Branch 0 taken 329922 times.
✓ Branch 1 taken 987930 times.
1317852 if(step<0) //up
7402 {
7403
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 162358 times.
✓ Branch 2 taken 167564 times.
329922 switch(clk3)
7404 {
7405 case left:
7406 162358 flip=0;
7407 162358 tile+=20;
7408 162358 break;
7409
7410 case right:
7411 167564 flip=0;
7412 167564 tile+=24;
7413 167564 break;
7414 }
7415 329922 }
7416
2/2
✓ Branch 0 taken 42115 times.
✓ Branch 1 taken 945815 times.
987930 else if(step==0)
7417 {
7418
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31831 times.
✓ Branch 2 taken 10284 times.
42115 switch(clk3)
7419 {
7420 case left:
7421 31831 flip=0;
7422 31831 tile+=8;
7423 31831 break;
7424
7425 case right:
7426 10284 flip=0;
7427 10284 tile+=12;
7428 10284 break;
7429 }
7430 42115 } //down
7431 else
7432 {
7433
3/3
✓ Branch 0 taken 64726 times.
✓ Branch 1 taken 445156 times.
✓ Branch 2 taken 435933 times.
945815 switch(clk3)
7434 {
7435 case left:
7436 445156 flip=0;
7437 445156 tile+=28;
7438 445156 break;
7439
7440 case right:
7441 435933 flip=0;
7442 435933 tile+=32;
7443 435933 break;
7444 }
7445 }
7446
7447
2/2
✓ Branch 0 taken 845637 times.
✓ Branch 1 taken 472215 times.
1317852 if(misc==0)
7448 {
7449 472215 tile+=f4;
7450 472215 }
7451
2/2
✓ Branch 0 taken 408849 times.
✓ Branch 1 taken 436788 times.
845637 else if(misc!=1)
7452 {
7453 436788 tile+=2;
7454 436788 }
7455 }
7456 1317852 break;
7457
7458 case aARMOS:
7459 {
7460
2/2
✓ Branch 0 taken 2153 times.
✓ Branch 1 taken 3306 times.
5459 if(!fading)
7461 {
7462 3306 tile += fx;
7463
7464
2/2
✓ Branch 0 taken 2459 times.
✓ Branch 1 taken 847 times.
3306 if(dir==up)
7465 847 tile += 2;
7466 3306 }
7467 }
7468 5459 break;
7469
7470 case aARMOS4:
7471 {
7472
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6349 times.
✓ Branch 2 taken 13276 times.
✓ Branch 3 taken 9550 times.
✓ Branch 4 taken 9345 times.
38520 switch(dir)
7473 {
7474 case up:
7475 6349 flip=0;
7476 6349 break;
7477
7478 case down:
7479 13276 flip=0;
7480 13276 tile+=4;
7481 13276 break;
7482
7483 case left:
7484 9550 flip=0;
7485 9550 tile+=8;
7486 9550 break;
7487
7488 case right:
7489 9345 flip=0;
7490 9345 tile+=12;
7491 9345 break;
7492 }
7493
7494
2/2
✓ Branch 0 taken 7161 times.
✓ Branch 1 taken 31359 times.
38520 if(!fading)
7495 {
7496 31359 tile+=f4;
7497 31359 }
7498 }
7499 38520 break;
7500
7501 case aGHINI:
7502 {
7503
4/4
✓ Branch 0 taken 14931 times.
✓ Branch 1 taken 18961 times.
✓ Branch 2 taken 40404 times.
✓ Branch 3 taken 374 times.
74670 switch(dir)
7504 {
7505 case 8:
7506 case 9:
7507 case up:
7508 14931 ++tile;
7509 14931 flip=0;
7510 14931 break;
7511
7512 case 15:
7513 374 ++tile;
7514 374 flip=1;
7515 374 break;
7516
7517 case 10:
7518 case 11:
7519 case right:
7520 18961 flip=1;
7521 18961 break;
7522
7523 default:
7524 40404 flip=0;
7525 40404 break;
7526 }
7527 }
7528 74670 break;
7529
7530 case a2FRMPOS:
7531 {
7532 1313148 tile+=posframe;
7533 }
7534 1313148 break;
7535
7536 case a4FRMPOS4DIR:
7537 {
7538 216057 basetile = n_frame_n_dir(4,4,0);
7539 // tile+=f2;
7540 216057 tile+=posframe;
7541 }
7542 216057 break;
7543
7544 case a4FRMPOS4DIRF:
7545 {
7546 basetile = n_frame_n_dir(4,4,0);
7547
7548 if(clk2>0) //stopped to fire
7549 {
7550 tile+=20;
7551
7552 if(clk2<17) //firing
7553 {
7554 tile+=20;
7555 }
7556 }
7557
7558 // tile+=f2;
7559 tile+=posframe;
7560 }
7561 break;
7562
7563 case a4FRMPOS8DIR:
7564 {
7565 3483844 tilerows = 2;
7566 3483844 int32_t n = tile;
7567 3483844 basetile = n_frame_n_dir(4,8,0);
7568 // tile+=f2;
7569 3483844 tile+=posframe;
7570 }
7571 3483844 break;
7572
7573 case a4FRMPOS8DIRF:
7574 {
7575 tilerows = 2;
7576 basetile = n_frame_n_dir(4,8,0);
7577
7578 if(clk2>0) //stopped to fire
7579 {
7580 tile+=40;
7581
7582 if(clk2<17) //firing
7583 {
7584 tile+=40;
7585 }
7586 }
7587
7588 tile+=posframe;
7589 }
7590 break;
7591
7592 case aNEWLEV:
7593 {
7594 281552 tiledir(dir,true);
7595
7596
4/5
✓ Branch 0 taken 92775 times.
✓ Branch 1 taken 45501 times.
✓ Branch 2 taken 18315 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124961 times.
281552 switch(misc)
7597 {
7598 case -1:
7599 case 0:
7600 92775 return;
7601
7602 case 1:
7603
7604 // case 5: cs = d->misc2; break;
7605 case 5:
7606 45501 cs = dmisc2;
7607 45501 break;
7608
7609 case 2:
7610 case 4:
7611 18315 tile += 20;
7612 18315 break;
7613
7614 case 3:
7615 124961 tile += 40;
7616 124961 break;
7617 }
7618
7619 188777 tile+=f4;
7620 }
7621 188777 break;
7622
7623 case aLEV:
7624 {
7625 219227 f4 = ((clk/5)&1);
7626
7627
4/5
✓ Branch 0 taken 106859 times.
✓ Branch 1 taken 24845 times.
✓ Branch 2 taken 11238 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76285 times.
219227 switch(misc)
7628 {
7629 case -1:
7630 case 0:
7631 106859 return;
7632
7633 case 1:
7634
7635 // case 5: tile += (f2) ? 1 : 0; cs = d->misc2; break;
7636 case 5:
7637 24845 tile += (f2) ? 1 : 0;
7638 24845 cs = dmisc2;
7639 24845 break;
7640
7641 case 2:
7642 case 4:
7643 11238 tile += 2;
7644 11238 break;
7645
7646 case 3:
7647 76285 tile += (f4) ? 4 : 3;
7648 76285 break;
7649 }
7650 }
7651 112368 break;
7652
7653 case aWALLM:
7654 {
7655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89141 times.
89141 if(!dummy_bool[1])
7656 {
7657 89141 tile += f2;
7658 89141 }
7659 }
7660 89141 break;
7661
7662 case aNEWWALLM:
7663 {
7664 233641 int32_t tempdir=0;
7665
7666
4/4
✓ Branch 0 taken 30389 times.
✓ Branch 1 taken 24290 times.
✓ Branch 2 taken 6721 times.
✓ Branch 3 taken 172241 times.
233641 switch(misc)
7667 {
7668 case 1:
7669 case 2:
7670 24290 tempdir=clk3;
7671 24290 break;
7672
7673 case 3:
7674 case 4:
7675 case 5:
7676 30389 tempdir=dir;
7677 30389 break;
7678
7679 case 6:
7680 case 7:
7681 6721 tempdir=clk3^1;
7682 6721 break;
7683 }
7684
7685 233641 tiledir(tempdir,true);
7686
7687
2/2
✓ Branch 0 taken 578 times.
✓ Branch 1 taken 233063 times.
233641 if(!dummy_bool[1])
7688 {
7689 233063 tile+=f4;
7690 233063 }
7691 }
7692 233641 break;
7693
7694 case a4FRMNODIR:
7695 {
7696 38974 tile+=f4;
7697 }
7698 38974 break;
7699
7700 } // switch(d->anim)
7701
7702 // flashing
7703 // if(d->flags2 & guy_flashing)
7704
2/2
✓ Branch 0 taken 22180744 times.
✓ Branch 1 taken 524534 times.
22705278 if(flags2 & guy_flashing)
7705 {
7706 524534 cs = (frame&3) + 6;
7707 524534 }
7708
7709
2/2
✓ Branch 0 taken 22673164 times.
✓ Branch 1 taken 32114 times.
22705278 if(flags2&guy_transparent)
7710 {
7711 32114 drawstyle=1;
7712 32114 }
7713
7714 22705278 int32_t change = tile-basetile;
7715
7716
3/6
✓ Branch 0 taken 1174288 times.
✓ Branch 1 taken 21530990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1174288 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22705278 if(extend > 2 && (!ignore_extend || get_qr(qr_BROKEN_BIG_ENEMY_ANIMATION)))
7717 {
7718
2/2
✓ Branch 0 taken 953842 times.
✓ Branch 1 taken 220446 times.
1174288 if(basetile/TILES_PER_ROW==(basetile+((txsz*change)/tilerows))/TILES_PER_ROW)
7719 {
7720 953842 tile=basetile+txsz*change;
7721 953842 }
7722 else
7723 {
7724 220446 tile=basetile+(txsz*change)+((tysz-1)*TILES_PER_ROW)*(((basetile+txsz*change)/TILES_PER_ROW)-(basetile/TILES_PER_ROW));
7725 }
7726 1174288 }
7727 else
7728 {
7729 21530990 tile=basetile+change;
7730 }
7731 22905054 }
7732
7733 53882 int32_t wpnsfx(int32_t wpn)
7734 {
7735
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17500 times.
✓ Branch 2 taken 283 times.
✓ Branch 3 taken 18023 times.
✓ Branch 4 taken 11644 times.
✓ Branch 5 taken 6432 times.
53882 switch(wpn)
7736 {
7737 case ewFireTrail:
7738 case ewFlame:
7739 case ewFlame2Trail:
7740 case ewFlame2:
7741 17500 return WAV_FIRE;
7742
7743 case ewWind:
7744 case ewMagic:
7745 283 return WAV_WAND;
7746
7747 case ewIce:
7748 return WAV_ZN1ICE;
7749
7750 case ewRock:
7751
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 6168 times.
6432 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1ROCK;
7752 6168 break;
7753
7754 case ewFireball2:
7755 case ewFireball:
7756
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 18016 times.
18023 if(get_qr(qr_MORESOUNDS)) return WAV_ZN1FIREBALL;
7757 18016 }
7758
7759 35828 return -1;
7760 53882 }
7761
7762 42799961 int32_t enemy::run_script(int32_t mode)
7763 {
7764
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42799961 if(switch_hooked && !get_qr(qr_SWITCHOBJ_RUN_SCRIPT)) return RUNSCRIPT_OK;
7765
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 42799961 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
42799961 if (script <= 0 || !doscript || FFCore.getQuestHeaderInfo(vZelda) < 0x255 || FFCore.system_suspend[susptNPCSCRIPTS])
7766 42799961 return RUNSCRIPT_OK;
7767 int32_t ret = RUNSCRIPT_OK;
7768 alloc_scriptmem();
7769 switch(mode)
7770 {
7771 case MODE_NORMAL:
7772 return ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7773 case MODE_WAITDRAW:
7774 if(waitdraw)
7775 {
7776 ret = ZScriptVersion::RunScript(ScriptType::NPC, script, getUID());
7777 waitdraw = 0;
7778 }
7779 break;
7780 }
7781 return ret;
7782 42799961 }
7783 ALLEGRO_COLOR enemy::hitboxColor(byte opacity) const
7784 {
7785 return al_map_rgba(255,0,0,opacity);
7786 }
7787 /********************************/
7788 /********* Guy Class **********/
7789 /********************************/
7790
7791 // good guys, fires, fairy, and other non-enemies
7792 // based on enemy class b/c guys in dungeons act sort of like enemies
7793 // also easier to manage all the guys this way
7794 1440 guy::guy(zfix X,zfix Y,int32_t Id,int32_t Clk,bool mg) : enemy(X,Y,Id,Clk)
7795 1440 {
7796 1440 mainguy=mg;
7797 1440 canfreeze=false;
7798 1440 dir=down;
7799
3/6
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1440 times.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
1440 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
7800 1440 hxofs=2;
7801 1440 hzsz=8;
7802 1440 hit_width=12;
7803 1440 hit_height=17;
7804
7805
10/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✓ Branch 5 taken 980 times.
✓ Branch 6 taken 450 times.
✓ Branch 7 taken 10 times.
✓ Branch 8 taken 205 times.
✓ Branch 9 taken 245 times.
✓ Branch 10 taken 14 times.
✓ Branch 11 taken 191 times.
1440 if(!superman && (!isdungeon() || id==gFAIRY || id==gFIRE || id==gZELDA))
7806 {
7807 1249 superman = 1;
7808 1249 hxofs=1000;
7809 1249 }
7810 1440 }
7811
7812 563152 bool guy::animate(int32_t index)
7813 {
7814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 563152 times.
563152 if(switch_hooked) return enemy::animate(index);
7815
6/6
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 2123 times.
✓ Branch 3 taken 269104 times.
✓ Branch 4 taken 1406 times.
✓ Branch 5 taken 717 times.
563152 if(mainguy && clk==0 && misc==0)
7816 {
7817 717 setupscreen();
7818 717 misc = 1;
7819 717 }
7820
7821
4/4
✓ Branch 0 taken 271227 times.
✓ Branch 1 taken 291925 times.
✓ Branch 2 taken 271014 times.
✓ Branch 3 taken 213 times.
563152 if(mainguy && fadeclk==0)
7822 213 return true;
7823
7824 562939 hp=256; // good guys never die...
7825
7826
4/4
✓ Branch 0 taken 295 times.
✓ Branch 1 taken 562644 times.
✓ Branch 2 taken 286 times.
✓ Branch 3 taken 9 times.
562939 if(hclk && !clk2)
7827 {
7828 // but if they get hit...
7829 9 ++clk2; // only do this once
7830
7831
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 if(!get_qr(qr_NOGUYFIRES))
7832 {
7833 1 addenemy(BSZ?64:72,68,eSHOOTFBALL,0);
7834 1 addenemy(BSZ?176:168,68,eSHOOTFBALL,0);
7835 1 }
7836 9 }
7837
7838 562939 return enemy::animate(index);
7839 563152 }
7840
7841 566391 void guy::draw(BITMAP *dest)
7842 {
7843 566391 update_enemy_frame();
7844
7845
6/6
✓ Branch 0 taken 274338 times.
✓ Branch 1 taken 292053 times.
✓ Branch 2 taken 14309 times.
✓ Branch 3 taken 260029 times.
✓ Branch 4 taken 7153 times.
✓ Branch 5 taken 7156 times.
566391 if(!mainguy || fadeclk<0 || fadeclk&1)
7846 559235 enemy::draw(dest);
7847 566391 }
7848
7849 /*******************************/
7850 /********* Enemies *********/
7851 /*******************************/
7852
7853 374 eFire::eFire(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7854 374 {
7855 374 clk4=0;
7856 374 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7857 // Spawn type
7858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if(flags & guy_fadeflicker)
7859 {
7860 clk=0;
7861 superman = 1;
7862 fading=fade_flicker;
7863 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7864 dir=down;
7865
7866 if(!canmove(down,(zfix)8,spw_none,false))
7867 clk3=int32_t(13.0/step);
7868 }
7869
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 else if(flags & guy_fadeinstant)
7870 {
7871 clk=0;
7872 }
7873 374 SIZEflags = d->SIZEflags;
7874
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7875 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7876 // al_trace("Enemy txsz:%i\n", txsz);
7877
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7879
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7880
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7881
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7882
1/2
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7883 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7884
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7886 {
7887 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
7888 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
7889 }
7890
7891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
374 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) d->zofs = (int32_t)zofs;
7892 374 }
7893
7894 78853 bool eFire::animate(int32_t index)
7895 {
7896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 78853 times.
78853 if(switch_hooked) return enemy::animate(index);
7897
2/4
✓ Branch 0 taken 78853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 78853 times.
78853 if(fallclk||drownclk) return enemy::animate(index);
7898
2/2
✓ Branch 0 taken 78278 times.
✓ Branch 1 taken 575 times.
78853 if(fading)
7899 {
7900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
575 if(++clk4 > 60)
7901 {
7902 clk4=0;
7903 superman=0;
7904 fading=0;
7905
7906 if(flags2&cmbflag_armos && z==0 && fakez==0)
7907 removearmos(x,y,ffcactivated);
7908
7909 clk2=0;
7910
7911 if(!canmove(down,(zfix)8,spw_none,false))
7912 {
7913 dir=0;
7914 y = y.getInt() & 0xF0;
7915 }
7916
7917 return Dead(index);
7918 }
7919
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 575 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
575 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
7920 removearmos(x,y,ffcactivated);
7921 575 }
7922
7923 78853 return enemy::animate(index);
7924 78853 }
7925
7926 166722 void eFire::draw(BITMAP *dest)
7927 {
7928 166722 update_enemy_frame();
7929 166722 enemy::draw(dest);
7930 166722 }
7931
7932 149 int32_t eFire::takehit(weapon *w, weapon* realweap)
7933 {
7934 149 int32_t wpnId = w->id;
7935 149 int32_t wpnDir = w->dir;
7936
7937
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
149 if(wpnId==wHammer && shield && (flags & guy_bkshield)
7938 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
7939 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
7940 {
7941 shield = false;
7942 flags &= ~(inv_left|inv_right|inv_back|inv_front);
7943
7944 if(get_qr(qr_BRKNSHLDTILES))
7945 o_tile=s_tile;
7946 }
7947
7948 149 int32_t ret = enemy::takehit(w,realweap);
7949 149 return ret;
7950 }
7951
7952 void eFire::break_shield()
7953 {
7954 if(!shield)
7955 return;
7956
7957 flags&=~(inv_front | inv_back | inv_left | inv_right);
7958 shield=false;
7959
7960 if(get_qr(qr_BRKNSHLDTILES))
7961 o_tile=s_tile;
7962 }
7963
7964 4900 eOther::eOther(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
7965 4900 {
7966 //zprint2("npct other::other\n");
7967 4900 clk4=0;
7968 4900 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
7969
7970 // Spawn type
7971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if(flags & guy_fadeflicker)
7972 {
7973 clk=0;
7974 superman = 1;
7975 fading=fade_flicker;
7976 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
7977 dir=down;
7978
7979 if(!canmove(down,(zfix)8,spw_none,false))
7980 clk3=int32_t(13.0/step);
7981 }
7982
2/2
✓ Branch 0 taken 4729 times.
✓ Branch 1 taken 171 times.
4900 else if(flags & guy_fadeinstant)
7983 {
7984 171 clk=0;
7985 171 }
7986 4900 SIZEflags = d->SIZEflags;
7987
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
7988 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
7989 // al_trace("Enemy txsz:%i\n", txsz);
7990
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
7991
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
7992
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
7993
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
7994
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
7995
1/2
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
7996 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
7997
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
7998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
7999 {
8000 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8001 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8002 }
8003
8004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4900 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8005 4900 }
8006
8007 917976 bool eOther::animate(int32_t index)
8008 {
8009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 917976 times.
917976 if(switch_hooked) return enemy::animate(index);
8010
2/4
✓ Branch 0 taken 917976 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 917976 times.
917976 if(fallclk||drownclk) return enemy::animate(index);
8011 //zprint2("npct other::animate\n");
8012
2/2
✓ Branch 0 taken 916640 times.
✓ Branch 1 taken 1336 times.
917976 if(fading)
8013 {
8014
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1335 times.
1336 if(++clk4 > 60)
8015 {
8016 1 clk4=0;
8017 1 superman=0;
8018 1 fading=0;
8019
8020
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1 if(flags2&cmbflag_armos && z==0 && fakez==0)
8021 removearmos(x,y,ffcactivated);
8022
8023 1 clk2=0;
8024
8025
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!canmove(down,(zfix)8,spw_none,false))
8026 {
8027 dir=0;
8028 y = y.getInt() & 0xF0;
8029 }
8030
8031 1 return Dead(index);
8032 }
8033
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1335 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8034 removearmos(x,y,ffcactivated);
8035 1335 }
8036
8037 917975 return enemy::animate(index);
8038 917976 }
8039
8040 944738 void eOther::draw(BITMAP *dest)
8041 {
8042 944738 update_enemy_frame();
8043 944738 enemy::draw(dest);
8044 944738 }
8045
8046 5691 int32_t eOther::takehit(weapon *w, weapon* realweap)
8047 {
8048 5691 int32_t wpnId = w->id;
8049 5691 int32_t wpnDir = w->dir;
8050
8051
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 5674 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
5691 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8052 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8053 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8054 {
8055 shield = false;
8056 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8057
8058 if(get_qr(qr_BRKNSHLDTILES))
8059 o_tile=s_tile;
8060 }
8061
8062 5691 int32_t ret = enemy::takehit(w,realweap);
8063 5691 return ret;
8064 }
8065
8066 void eOther::break_shield()
8067 {
8068 if(!shield)
8069 return;
8070
8071 flags&=~(inv_front | inv_back | inv_left | inv_right);
8072 shield=false;
8073
8074 if(get_qr(qr_BRKNSHLDTILES))
8075 o_tile=s_tile;
8076 }
8077
8078
8079 eScript::eScript(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8080 {
8081 clk4=0;
8082 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8083
8084 // Spawn type
8085 if(flags & guy_fadeflicker)
8086 {
8087 clk=0;
8088 superman = 1;
8089 fading=fade_flicker;
8090 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8091 dir=down;
8092
8093 if(!canmove(down,(zfix)8,spw_none,false))
8094 clk3=int32_t(13.0/step);
8095 }
8096 else if(flags & guy_fadeinstant)
8097 {
8098 clk=0;
8099 }
8100 SIZEflags = d->SIZEflags;
8101 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8102 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8103 // al_trace("Enemy txsz:%i\n", txsz);
8104 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8105 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8106 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8107 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8108 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8109 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8110 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8111 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8112 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8113 {
8114 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8115 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8116 }
8117
8118 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8119 }
8120
8121 bool eScript::animate(int32_t index)
8122 {
8123 if(switch_hooked) return enemy::animate(index);
8124 if(fallclk||drownclk) return enemy::animate(index);
8125 if(fading)
8126 {
8127 if(++clk4 > 60)
8128 {
8129 clk4=0;
8130 superman=0;
8131 fading=0;
8132
8133 if(flags2&cmbflag_armos && z==0 && fakez==0)
8134 removearmos(x,y,ffcactivated);
8135
8136 clk2=0;
8137
8138 if(!canmove(down,(zfix)8,spw_none,false))
8139 {
8140 dir=0;
8141 y = y.getInt() & 0xF0;
8142 }
8143
8144 return Dead(index);
8145 }
8146 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8147 removearmos(x,y,ffcactivated);
8148 }
8149
8150 return enemy::animate(index);
8151 }
8152
8153 void eScript::draw(BITMAP *dest)
8154 {
8155 update_enemy_frame();
8156 enemy::draw(dest);
8157 }
8158
8159 int32_t eScript::takehit(weapon *w, weapon* realweap)
8160 {
8161 int32_t wpnId = w->id;
8162 int32_t wpnDir = w->dir;
8163
8164 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8165 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8166 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8167 {
8168 shield = false;
8169 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8170
8171 if(get_qr(qr_BRKNSHLDTILES))
8172 o_tile=s_tile;
8173 }
8174
8175 int32_t ret = enemy::takehit(w,realweap);
8176 return ret;
8177 }
8178
8179 void eScript::break_shield()
8180 {
8181 if(!shield)
8182 return;
8183
8184 flags&=~(inv_front | inv_back | inv_left | inv_right);
8185 shield=false;
8186
8187 if(get_qr(qr_BRKNSHLDTILES))
8188 o_tile=s_tile;
8189 }
8190
8191
8192 eFriendly::eFriendly(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8193 {
8194 clk4=0;
8195 hyofs = -32768; //No hitbox initially.
8196 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
8197
8198 // Spawn type
8199 if(flags & guy_fadeflicker)
8200 {
8201 clk=0;
8202 superman = 1;
8203 fading=fade_flicker;
8204 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8205 dir=down;
8206
8207 if(!canmove(down,(zfix)8,spw_none,false))
8208 clk3=int32_t(13.0/step);
8209 }
8210 else if(flags & guy_fadeinstant)
8211 {
8212 clk=0;
8213 }
8214 SIZEflags = d->SIZEflags;
8215 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8216 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8217 // al_trace("Enemy txsz:%i\n", txsz);
8218 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8219 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8220 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8221 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8222 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8223 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8224 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8225 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8226 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8227 {
8228 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8229 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8230 }
8231
8232 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8233 }
8234
8235 bool eFriendly::animate(int32_t index)
8236 {
8237 if(switch_hooked) return enemy::animate(index);
8238 if(fallclk||drownclk) return enemy::animate(index);
8239 if(fading)
8240 {
8241 if(++clk4 > 60)
8242 {
8243 clk4=0;
8244 superman=0;
8245 fading=0;
8246
8247 if(flags2&cmbflag_armos && z==0 && fakez==0)
8248 removearmos(x,y,ffcactivated);
8249
8250 clk2=0;
8251
8252 if(!canmove(down,(zfix)8,spw_none,false))
8253 {
8254 dir=0;
8255 y = y.getInt() & 0xF0;
8256 }
8257
8258 return Dead(index);
8259 }
8260 else if(flags2&cmbflag_armos && z==0 && fakez==0 && clk==0)
8261 removearmos(x,y,ffcactivated);
8262 }
8263
8264 return enemy::animate(index);
8265 }
8266
8267 void eFriendly::draw(BITMAP *dest)
8268 {
8269 update_enemy_frame();
8270 enemy::draw(dest);
8271 }
8272
8273 int32_t eFriendly::takehit(weapon *w, weapon* realweap)
8274 {
8275 int32_t wpnId = w->id;
8276 int32_t wpnDir = w->dir;
8277
8278 if(wpnId==wHammer && shield && (flags & guy_bkshield)
8279 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
8280 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
8281 {
8282 shield = false;
8283 flags &= ~(inv_left|inv_right|inv_back|inv_front);
8284
8285 if(get_qr(qr_BRKNSHLDTILES))
8286 o_tile=s_tile;
8287 }
8288
8289 int32_t ret = enemy::takehit(w,realweap);
8290 return ret;
8291 }
8292
8293 void eFriendly::break_shield()
8294 {
8295 if(!shield)
8296 return;
8297
8298 flags&=~(inv_front | inv_back | inv_left | inv_right);
8299 shield=false;
8300
8301 if(get_qr(qr_BRKNSHLDTILES))
8302 o_tile=s_tile;
8303 }
8304
8305
8306 354130 void enemy::removearmos(int32_t ax,int32_t ay, word ffcactive)
8307 {
8308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 354130 times.
354130 if (ffcactive)
8309 {
8310 removearmosffc(ffcactive-1);
8311 return;
8312 }
8313
2/2
✓ Branch 0 taken 353464 times.
✓ Branch 1 taken 666 times.
354130 if(did_armos)
8314 {
8315 353464 return;
8316 }
8317
8318 666 did_armos=true;
8319 666 ax&=0xF0;
8320 666 ay&=0xF0;
8321 666 int32_t cd = (ax>>4)+ay;
8322 666 int32_t f = MAPFLAG(ax,ay);
8323 666 int32_t f2 = MAPCOMBOFLAG(ax,ay);
8324
8325
2/2
✓ Branch 0 taken 545 times.
✓ Branch 1 taken 121 times.
666 if(combobuf[tmpscr->data[cd]].type!=cARMOS)
8326 {
8327 545 return;
8328 }
8329
8330 121 tmpscr->data[cd] = tmpscr->undercombo;
8331 121 tmpscr->cset[cd] = tmpscr->undercset;
8332 121 tmpscr->sflag[cd] = 0;
8333
8334
3/4
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 101 times.
121 if(f == mfARMOS_SECRET || f2 == mfARMOS_SECRET)
8335 {
8336 20 tmpscr->data[cd] = tmpscr->secretcombo[sSTAIRS];
8337 20 tmpscr->cset[cd] = tmpscr->secretcset[sSTAIRS];
8338 20 tmpscr->sflag[cd]=tmpscr->secretflag[sSTAIRS];
8339 20 sfx(tmpscr->secretsfx);
8340 20 }
8341
8342
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 119 times.
121 if(f == mfARMOS_ITEM || f2 == mfARMOS_ITEM)
8343 {
8344
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8345 {
8346 2 additem(ax,ay,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8347 2 sfx(tmpscr->secretsfx);
8348 2 }
8349 2 }
8350
8351 121 putcombo(scrollbuf,ax,ay,tmpscr->data[cd],tmpscr->cset[cd]);
8352 354130 }
8353
8354 void enemy::removearmosffc(int32_t pos)
8355 {
8356 if(did_armos)
8357 {
8358 return;
8359 }
8360
8361 did_armos=true;
8362 ffcdata& ffc = tmpscr->ffcs[pos];
8363 newcombo const& cmb = combobuf[ffc.data];
8364 int32_t f2 = cmb.flag;
8365
8366 if(cmb.type!=cARMOS)
8367 {
8368 return;
8369 }
8370
8371 zc_ffc_set(ffc, tmpscr->undercombo);
8372 ffc.cset = tmpscr->undercset;
8373
8374 if(f2 == mfARMOS_SECRET)
8375 {
8376 zc_ffc_set(ffc, tmpscr->secretcombo[sSTAIRS]);
8377 ffc.cset = tmpscr->secretcset[sSTAIRS];
8378 sfx(tmpscr->secretsfx);
8379 }
8380
8381 if(f2 == mfARMOS_ITEM)
8382 {
8383 if(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN))
8384 {
8385 additem(ffc.x,ffc.y,tmpscr->catchall, (ipONETIME2 + ipBIGRANGE) | ((tmpscr->flags3&fHOLDITEM) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
8386 sfx(tmpscr->secretsfx);
8387 }
8388 }
8389
8390 putcombo(scrollbuf,ffc.x,ffc.y,ffc.data,ffc.cset);
8391 }
8392
8393
8394 140 eGhini::eGhini(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8395 140 {
8396 140 fading=fade_flicker;
8397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
8398 140 dir=12;
8399 140 movestatus=1;
8400
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 step=0;
8401 140 clk=0;
8402 140 clk4=0;
8403 140 SIZEflags = d->SIZEflags;
8404
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8405 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8406 // al_trace("Enemy txsz:%i\n", txsz);
8407
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8408
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8409
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8410
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8411
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8412
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8413 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8414
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8416 {
8417 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8418 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8419 }
8420
8421
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 140 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
140 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8422 140 }
8423
8424 51269 bool eGhini::animate(int32_t index)
8425 {
8426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51269 times.
51269 if(switch_hooked) return enemy::animate(index);
8427
2/4
✓ Branch 0 taken 51269 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 51269 times.
51269 if(fallclk||drownclk) return enemy::animate(index);
8428
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 51233 times.
51269 if(dying)
8429 36 return Dead(index);
8430
8431
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51233 times.
51233 if(dmisc1)
8432 {
8433
2/2
✓ Branch 0 taken 42826 times.
✓ Branch 1 taken 8407 times.
51233 if(misc)
8434 {
8435
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 if(clk4>160)
8436 31041 misc=2;
8437
8438
2/2
✓ Branch 0 taken 11785 times.
✓ Branch 1 taken 31041 times.
42826 floater_walk((misc==1)?0:rate,hrate,zslongToFix(dstep*100),zslongToFix(dstep*10),10,dmisc16,dmisc17); //120,10);
8439 42826 removearmos(x,y,ffcactivated);
8440 42826 }
8441
2/2
✓ Branch 0 taken 8272 times.
✓ Branch 1 taken 135 times.
8407 else if(clk4>=60)
8442 {
8443 135 misc=1;
8444 135 clk3=32;
8445 135 fading=0;
8446
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if (ffcactivated > 0)
8447 {
8448 guygridffc[ffcactivated-1] = 0;
8449 removearmosffc(ffcactivated-1);
8450 }
8451 else
8452 {
8453 135 guygrid[(int32_t(y)&0xF0)+(int32_t(x)>>4)]=0;
8454 135 removearmos(x,y);
8455 }
8456 135 }
8457 51233 }
8458
8459 51233 clk4++;
8460
8461 51233 return enemy::animate(index);
8462 51269 }
8463
8464 102598 void eGhini::draw(BITMAP *dest)
8465 {
8466 102598 update_enemy_frame();
8467 102598 enemy::draw(dest);
8468 102598 }
8469
8470 2 void eGhini::kickbucket()
8471 {
8472 2 hp=-1000; // don't call death_sfx()
8473 2 }
8474
8475
2/4
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
5882 eTektite::eTektite(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8476 2941 {
8477
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 old_y=y;
8478 2941 dir=down;
8479 2941 misc=1;
8480 2941 clk=-15;
8481
8482
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 573 times.
2941 if(!BSZ)
8483
1/2
✓ Branch 0 taken 2368 times.
✗ Branch 1 not taken.
2368 clk*=zc_oldrand()%3+1;
8484
8485 // avoid divide by 0 errors
8486
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc1 == 0)
8487 dmisc1 = 24;
8488
8489
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if(dmisc2 == 0)
8490 dmisc2 = 3;
8491
8492 //nets+760;
8493 2941 SIZEflags = d->SIZEflags;
8494
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8495 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8496 // al_trace("Enemy txsz:%i\n", txsz);
8497
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8498
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8499
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8500
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8501
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8502
1/2
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8503 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8504
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8506 {
8507 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8508 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8509 }
8510
8511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2941 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2941 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8512 2941 }
8513
8514 910945 bool eTektite::animate(int32_t index)
8515 {
8516
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 910945 times.
910945 if(switch_hooked) return enemy::animate(index);
8517
4/4
✓ Branch 0 taken 903407 times.
✓ Branch 1 taken 7538 times.
✓ Branch 2 taken 7538 times.
✓ Branch 3 taken 909605 times.
910945 if(fallclk||drownclk) return enemy::animate(index);
8518
2/2
✓ Branch 0 taken 19019 times.
✓ Branch 1 taken 890586 times.
909605 if(dying)
8519 19019 return Dead(index);
8520
8521
2/2
✓ Branch 0 taken 867887 times.
✓ Branch 1 taken 22699 times.
890586 if(clk==0)
8522 {
8523 22699 removearmos(x,y,ffcactivated);
8524 22699 }
8525
8526
2/2
✓ Branch 0 taken 557452 times.
✓ Branch 1 taken 333134 times.
890586 if(get_qr(qr_ENEMIESZAXIS))
8527 {
8528 333134 y=floor_y;
8529 333134 }
8530
8531
9/10
✓ Branch 0 taken 805094 times.
✓ Branch 1 taken 85492 times.
✓ Branch 2 taken 798089 times.
✓ Branch 3 taken 7005 times.
✓ Branch 4 taken 798089 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11176 times.
✓ Branch 7 taken 786913 times.
✓ Branch 8 taken 3360 times.
✓ Branch 9 taken 11586 times.
890586 if(clk>=0 && !stunclk && !frozenclock && (!watch || misc==0))
8532 {
8533
4/4
✓ Branch 0 taken 9968 times.
✓ Branch 1 taken 310803 times.
✓ Branch 2 taken 206484 times.
✓ Branch 3 taken 271244 times.
798499 switch(misc)
8534 {
8535 case 0: // normal
8536
2/2
✓ Branch 0 taken 304080 times.
✓ Branch 1 taken 6723 times.
310803 if(!(zc_oldrand()%dmisc1))
8537 {
8538 6723 misc=1;
8539 6723 clk2=32;
8540 6723 }
8541
8542 310803 break;
8543
8544 case 1: // waiting to pounce
8545
2/2
✓ Branch 0 taken 195359 times.
✓ Branch 1 taken 11125 times.
206484 if(--clk2<=0)
8546 {
8547 11125 int32_t r=zc_oldrand();
8548 11125 misc=2;
8549 11125 step=0-(zslongToFix(dstep*100)); // initial speed
8550 11125 clk3=(r&1)+2; // left or right
8551 11125 clk2start=clk2=(r&31)+10; // flight time
8552
8553
2/2
✓ Branch 0 taken 9762 times.
✓ Branch 1 taken 1363 times.
11125 if(y<32) clk2+=2; // make them come down from top of screen
8554
8555
2/2
✓ Branch 0 taken 8659 times.
✓ Branch 1 taken 2466 times.
11125 if(y>112) clk2-=2; // make them go back up
8556
8557 11125 cstart=c = 9-((r&31)>>3); // time before gravity kicks in
8558 11125 }
8559
8560 206484 break;
8561
8562 case 2: // in flight
8563 271244 move(step);
8564
8565
2/2
✓ Branch 0 taken 130352 times.
✓ Branch 1 taken 140892 times.
271244 if(step>0) //going down
8566 {
8567
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 130196 times.
130352 if(COMBOTYPE(x+8,y+16)==cNOJUMPZONE)
8568 {
8569 156 step=0-step;
8570 156 }
8571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(COMBOTYPE(x+8,y+16)==cNOENEMY)
8572 {
8573 step=0-step;
8574 }
8575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(ispitfall(x+8,y+16))
8576 {
8577 step=0-step;
8578 }
8579
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 130196 times.
130196 else if(MAPFLAG(x+8,y+16)==mfNOENEMY)
8580 {
8581 step=0-step;
8582 }
8583
1/2
✓ Branch 0 taken 130196 times.
✗ Branch 1 not taken.
130196 else if(MAPCOMBOFLAG(x+8,y+16)==mfNOENEMY)
8584 {
8585 step=0-step;
8586 }
8587 130352 }
8588
2/2
✓ Branch 0 taken 9095 times.
✓ Branch 1 taken 131797 times.
140892 else if(step<0)
8589 {
8590
2/2
✓ Branch 0 taken 219 times.
✓ Branch 1 taken 131578 times.
131797 if(COMBOTYPE(x+8,y)==cNOJUMPZONE)
8591 {
8592 219 step=0-step;
8593 219 }
8594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(COMBOTYPE(x+8,y)==cNOENEMY)
8595 {
8596 step=0-step;
8597 }
8598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(ispitfall(x+8,y))
8599 {
8600 step=0-step;
8601 }
8602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131578 times.
131578 else if(MAPFLAG(x+8,y)==mfNOENEMY)
8603 {
8604 step=0-step;
8605 }
8606
1/2
✓ Branch 0 taken 131578 times.
✗ Branch 1 not taken.
131578 else if(MAPCOMBOFLAG(x+8,y)==mfNOENEMY)
8607 {
8608 step=0-step;
8609 }
8610 131797 }
8611
8612
2/2
✓ Branch 0 taken 134483 times.
✓ Branch 1 taken 136761 times.
271244 if(clk3==left)
8613 {
8614
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 134382 times.
134483 if(COMBOTYPE(x,y+8)==cNOJUMPZONE)
8615 {
8616 101 clk3^=1;
8617 101 }
8618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(COMBOTYPE(x,y+8)==cNOENEMY)
8619 {
8620 clk3^=1;
8621 }
8622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(ispitfall(x,y+8))
8623 {
8624 clk3^=1;
8625 }
8626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134382 times.
134382 else if(MAPFLAG(x,y+8)==mfNOENEMY)
8627 {
8628 clk3^=1;
8629 }
8630
1/2
✓ Branch 0 taken 134382 times.
✗ Branch 1 not taken.
134382 else if(MAPCOMBOFLAG(x,y+8)==mfNOENEMY)
8631 {
8632 clk3^=1;
8633 }
8634 134483 }
8635 else
8636 {
8637
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 136670 times.
136761 if(COMBOTYPE(x+16,y+8)==cNOJUMPZONE)
8638 {
8639 91 clk3^=1;
8640 91 }
8641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(COMBOTYPE(x+16,y+8)==cNOENEMY)
8642 {
8643 clk3^=1;
8644 }
8645
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(ispitfall(x+16,y+8))
8646 {
8647 clk3^=1;
8648 }
8649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136670 times.
136670 else if(MAPFLAG(x+16,y+8)==mfNOENEMY)
8650 {
8651 clk3^=1;
8652 }
8653
1/2
✓ Branch 0 taken 136670 times.
✗ Branch 1 not taken.
136670 else if(MAPCOMBOFLAG(x+16,y+8)==mfNOENEMY)
8654 {
8655 clk3^=1;
8656 }
8657 }
8658
8659 271244 --c;
8660
8661
4/4
✓ Branch 0 taken 81892 times.
✓ Branch 1 taken 189352 times.
✓ Branch 2 taken 178175 times.
✓ Branch 3 taken 93069 times.
271244 if(c<0 && step<zslongToFix(dstep*100))
8662 {
8663 93069 step+=zslongToFix(dmisc3*100);
8664 93069 }
8665
8666 271244 int32_t nb=get_qr(qr_NOBORDER) ? 16 : 0;
8667
8668
2/2
✓ Branch 0 taken 270922 times.
✓ Branch 1 taken 322 times.
271244 if(x<=16-nb) clk3=right;
8669
8670
2/2
✓ Branch 0 taken 270702 times.
✓ Branch 1 taken 542 times.
271244 if(x>=224+nb) clk3=left;
8671
8672 271244 x += (clk3==left) ? -1 : 1;
8673
8674
4/4
✓ Branch 0 taken 15373 times.
✓ Branch 1 taken 255871 times.
✓ Branch 2 taken 4984 times.
✓ Branch 3 taken 250887 times.
271244 if((--clk2<=0 && y>=16-nb) || y>=144+nb)
8675 {
8676
4/4
✓ Branch 0 taken 661 times.
✓ Branch 1 taken 9728 times.
✓ Branch 2 taken 484 times.
✓ Branch 3 taken 177 times.
20357 if(y>=144+nb && get_qr(qr_ENEMIESZAXIS))
8677 {
8678 177 step=0-step;
8679 177 y--;
8680 177 }
8681
2/2
✓ Branch 0 taken 2320 times.
✓ Branch 1 taken 7892 times.
10212 else if(zc_oldrand()%dmisc2) //land and wait
8682 {
8683 7892 clk=misc=0;
8684 7892 } //land and jump again
8685 else
8686 {
8687 2320 misc=1;
8688 2320 clk2=0;
8689 }
8690 10389 }
8691
8692 261276 break;
8693 } // switch
8694 788531 }
8695
8696
4/4
✓ Branch 0 taken 333134 times.
✓ Branch 1 taken 551254 times.
✓ Branch 2 taken 226451 times.
✓ Branch 3 taken 106683 times.
884388 if(get_qr(qr_ENEMIESZAXIS) && misc==2)
8697 {
8698
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 106683 times.
106683 if (moveflags & FLAG_USE_FAKE_Z)
8699 {
8700 int32_t tempy = floor_y;
8701 fakez=zc_max(0,zc_min(clk2start-clk2,clk2));
8702 floor_y = y;
8703 y=tempy-fakez;
8704 old_y = y;
8705 }
8706 else
8707 {
8708 106683 int32_t tempy = floor_y;
8709
6/6
✓ Branch 0 taken 53507 times.
✓ Branch 1 taken 53176 times.
✓ Branch 2 taken 100927 times.
✓ Branch 3 taken 5756 times.
✓ Branch 4 taken 49170 times.
✓ Branch 5 taken 51757 times.
106683 z=zc_max(0,zc_min(clk2start-clk2,clk2));
8710 106683 floor_y = y;
8711 106683 y=tempy-z;
8712 106683 old_y = y;
8713 }
8714 106683 }
8715
8716
4/4
✓ Branch 0 taken 7005 times.
✓ Branch 1 taken 877383 times.
✓ Branch 2 taken 1407 times.
✓ Branch 3 taken 5598 times.
884388 if(stunclk && (clk&31)==1)
8717 5598 clk=0;
8718
8719 884388 return enemy::animate(index);
8720 903407 }
8721
8722 330586 void eTektite::drawshadow(BITMAP *dest,bool translucent)
8723 {
8724
5/6
✓ Branch 0 taken 161030 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 161030 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 136696 times.
✓ Branch 5 taken 24334 times.
330586 if(z<1 && fakez<1 && get_qr(qr_ENEMIESZAXIS))
8725 24334 return;
8726
8727 306252 int32_t tempy=yofs;
8728 306252 int32_t fdiv = frate/4;
8729
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
8730
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 int32_t f2=get_qr(qr_NEWENEMYTILES)?
8731 306252 efrate:((clk>=(frate>>1))?1:0);
8732 306252 flip = 0;
8733 306252 shadowtile = wpnsbuf[spr_shadow].tile;
8734
8735
1/2
✓ Branch 0 taken 306252 times.
✗ Branch 1 not taken.
306252 if(get_qr(qr_NEWENEMYTILES))
8736 {
8737
2/2
✓ Branch 0 taken 200675 times.
✓ Branch 1 taken 105577 times.
306252 if(misc==0)
8738 {
8739 105577 shadowtile+=f2;
8740 105577 }
8741
2/2
✓ Branch 0 taken 91502 times.
✓ Branch 1 taken 109173 times.
200675 else if(misc!=1)
8742 109173 shadowtile+=2;
8743 306252 }
8744 else
8745 {
8746 if(misc==0)
8747 {
8748 shadowtile += f2 ? 1 : 0;
8749 }
8750 else if(misc!=1)
8751 {
8752 ++shadowtile;
8753 }
8754 }
8755
8756 306252 yofs+=8;
8757
8758
4/4
✓ Branch 0 taken 136696 times.
✓ Branch 1 taken 169556 times.
✓ Branch 2 taken 84452 times.
✓ Branch 3 taken 52244 times.
306252 if(!get_qr(qr_ENEMIESZAXIS) && misc==2)
8759 {
8760
6/6
✓ Branch 0 taken 26557 times.
✓ Branch 1 taken 25687 times.
✓ Branch 2 taken 48843 times.
✓ Branch 3 taken 3401 times.
✓ Branch 4 taken 24406 times.
✓ Branch 5 taken 24437 times.
52244 yofs+=zc_max(0,zc_min(clk2start-clk2,clk2));
8761 52244 }
8762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 306252 times.
306252 if(!shadow_overpit(this))
8763 306252 enemy::drawshadow(dest,translucent);
8764 306252 yofs=tempy;
8765 330586 }
8766
8767 1500560 void eTektite::draw(BITMAP *dest)
8768 {
8769 1500560 update_enemy_frame();
8770 1500560 enemy::draw(dest);
8771 1500560 }
8772
8773 413 eItemFairy::eItemFairy(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8774 413 {
8775
2/4
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
413 step=zslongToFix(guysbuf[id&0xFFF].step*100);
8776 413 superman=1;
8777 413 dir=8;
8778 413 hxofs=1000;
8779 413 mainguy=false;
8780 413 count_enemy=false;
8781
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8782 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8783 // al_trace("Enemy txsz:%i\n", txsz);
8784
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
8785
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
8786
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
8787
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
413 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
8788
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
8789
1/2
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
8790 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8791
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
8792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8793 {
8794 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
8795 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8796 }
8797
8798
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 413 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
413 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
8799 413 }
8800
8801 228794 bool eItemFairy::animate(int32_t index)
8802 {
8803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(switch_hooked) return enemy::animate(index);
8804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 228794 times.
228794 if(dying)
8805 return Dead(index);
8806
8807 //if(clk>32)
8808 228794 misc=1;
8809 228794 bool w=watch;
8810 228794 watch=false;
8811 228794 variable_walk_8(misc?3:0,0,8,spw_floater);
8812 228794 watch=w;
8813
8814
2/2
✓ Branch 0 taken 1107 times.
✓ Branch 1 taken 227687 times.
228794 if(clk==0)
8815 {
8816 1107 removearmos(x,y,ffcactivated);
8817 1107 }
8818
8819 228794 return enemy::animate(index);
8820 228794 }
8821
8822 458954 void eItemFairy::draw(BITMAP *dest)
8823 {
8824 //these are here to bypass compiler warnings about unused arguments
8825 458954 dest=dest;
8826 458954 }
8827
8828 1048 ePeahat::ePeahat(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8829 1048 {
8830 //floater_walk(int32_t rate,int32_t newclk,zfix ms,zfix ss,int32_t s,int32_t p, int32_t g)
8831
10/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1048 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1048 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1048 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1048 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1048 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1048 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1048 times.
✗ Branch 19 not taken.
1048 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, dmisc16,dmisc17); // 80, 16);
8832 1048 dir=8;
8833 1048 movestatus=1;
8834 1048 clk=0;
8835
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 step=0;
8836 //nets+720;
8837 1048 SIZEflags = d->SIZEflags;
8838
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8839 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8840 // al_trace("Enemy txsz:%i\n", txsz);
8841
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8842
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8843
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8844
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8845
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8846
1/2
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8847 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8848
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8850 {
8851 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8852 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8853 }
8854
8855
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1048 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1048 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8856 1048 }
8857
8858 300264 bool ePeahat::animate(int32_t index)
8859 {
8860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 300264 times.
300264 if(switch_hooked) return enemy::animate(index);
8861
2/4
✓ Branch 0 taken 300264 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 300264 times.
300264 if(fallclk||drownclk) return enemy::animate(index);
8862
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 300186 times.
300264 if(slide())
8863 {
8864 78 return false;
8865 }
8866
8867
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 299672 times.
300186 if(dying)
8868 514 return Dead(index);
8869
8870
2/2
✓ Branch 0 taken 297855 times.
✓ Branch 1 taken 1817 times.
299672 if(clk==0)
8871 {
8872 1817 removearmos(x,y,ffcactivated);
8873 1817 }
8874
8875
4/4
✓ Branch 0 taken 296892 times.
✓ Branch 1 taken 2780 times.
✓ Branch 2 taken 144455 times.
✓ Branch 3 taken 152437 times.
299672 if(stunclk==0 && clk>96)
8876 152437 misc=1;
8877
8878
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
299672 if(!watch)
8879
2/2
✓ Branch 0 taken 197329 times.
✓ Branch 1 taken 99941 times.
297270 floater_walk(misc?rate:0, hrate, zslongToFix(dstep*100),zslongToFix(dstep*10), 10, 80, 16);
8880
8881
3/4
✓ Branch 0 taken 100018 times.
✓ Branch 1 taken 199654 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 100018 times.
299672 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
8882 {
8883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100018 times.
100018 if (moveflags & FLAG_USE_FAKE_Z) fakez=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8884 100018 else z=int32_t(step*1.1/((zslongToFix(dstep*10))*1.1));
8885 100018 }
8886
8887
4/4
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 297270 times.
✓ Branch 2 taken 768 times.
✓ Branch 3 taken 1634 times.
299672 if(watch && get_qr(qr_PEAHATCLOCKVULN))
8888 1634 superman=0;
8889 else
8890
2/2
✓ Branch 0 taken 6888 times.
✓ Branch 1 taken 291150 times.
298038 superman=(movestatus && !get_qr(qr_ENEMIESZAXIS)) ? 1 : 0;
8891 //stunclk=0; //Not sure what was going on here, or what was intended. Why was this set to 0? -Z
8892
2/2
✓ Branch 0 taken 196019 times.
✓ Branch 1 taken 103653 times.
299672 if ( FFCore.getQuestHeaderInfo(vZelda) >= 0x250 )
8893 {
8894
2/2
✓ Branch 0 taken 193242 times.
✓ Branch 1 taken 2777 times.
196019 if ( stunclk ) --stunclk;
8895 196019 }
8896 103653 else stunclk = 0; //Was probably this way in 2.10 quests. if not, then we never need to clear it. -Z
8897 //Pretty sure this was always an error. -Z ( 14FEB2019 )
8898
8899
8900
2/2
✓ Branch 0 taken 299448 times.
✓ Branch 1 taken 224 times.
299672 if(x<16) dir=right; //this is ugly, but so is moving or creating these guys with scripts.
8901
8902 299672 return enemy::animate(index);
8903 300264 }
8904
8905 126460 void ePeahat::drawshadow(BITMAP *dest, bool translucent)
8906 {
8907 126460 int32_t tempy=yofs;
8908 126460 flip = 0;
8909 126460 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
8910
8911
2/2
✓ Branch 0 taken 88089 times.
✓ Branch 1 taken 38371 times.
126460 if(!get_qr(qr_ENEMIESZAXIS))
8912 {
8913 38371 yofs+=8;
8914 38371 yofs+=int32_t(step/zslongToFix(dstep*10));
8915 38371 }
8916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 126460 times.
126460 if(!shadow_overpit(this))
8917 126460 enemy::drawshadow(dest,translucent);
8918 126460 yofs=tempy;
8919 126460 }
8920
8921 694948 void ePeahat::draw(BITMAP *dest)
8922 {
8923 694948 update_enemy_frame();
8924 694948 enemy::draw(dest);
8925 694948 }
8926
8927 1383 int32_t ePeahat::takehit(weapon *w, weapon* realweap)
8928 {
8929 1383 int32_t wpnId = w->id;
8930 1383 int32_t enemyHitWeapon = w->parentitem;
8931
8932
3/6
✓ Branch 0 taken 1383 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1383 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1383 times.
1383 if(dying || clk<0 || hclk>0)
8933 return 0;
8934
8935
4/4
✓ Branch 0 taken 1186 times.
✓ Branch 1 taken 197 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 129 times.
1542 if(superman && !(wpnId==wSBomb) // vulnerable to super bombs
8936 // fire boomerang, for nailing peahats
8937
4/6
✓ Branch 0 taken 1186 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1027 times.
✓ Branch 3 taken 159 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 159 times.
1186 && !(wpnId==wBrang && (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_brang))>0))
8938 1156 return 0;
8939
8940 // Time for a kludge...
8941 227 int32_t s = superman;
8942 227 superman = 0;
8943 227 int32_t ret = enemy::takehit(w,realweap);
8944 227 superman = s;
8945
8946 // Anyway...
8947
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 141 times.
227 if(stunclk == 160)
8948 {
8949 141 clk2=0;
8950 141 movestatus=0;
8951 141 misc=0;
8952 141 clk=0;
8953 141 step=0;
8954 141 }
8955
8956 227 return ret;
8957 1383 }
8958
8959 // auomatically kill off enemy (for rooms with ringleaders)
8960 void ePeahat::kickbucket()
8961 {
8962 hp=-1000; // don't call death_sfx()
8963 }
8964
8965 1694 eLeever::eLeever(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
8966 1694 {
8967 // if(d->misc1==0) { misc=-1; clk-=16; } //Line of Sight leevers
8968
2/2
✓ Branch 0 taken 753 times.
✓ Branch 1 taken 941 times.
1694 if(dmisc1==0)
8969 {
8970 941 misc=-1; //Line of Sight leevers
8971 941 clk-=16;
8972 941 }
8973 1694 clk3 = 0;
8974 //nets+1460;
8975
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 temprule=(get_qr(qr_NEWENEMYTILES)) != 0;
8976 1694 submerged = false;
8977 1694 SIZEflags = d->SIZEflags;
8978
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
8979 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
8980 // al_trace("Enemy txsz:%i\n", txsz);
8981
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
8982
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
8983
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
8984
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
8985
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
8986
1/2
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
8987 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
8988
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
8989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
8990 {
8991 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
8992 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
8993 }
8994
8995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1694 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
8996 1694 }
8997
8998 bool eLeever::isSubmerged() const
8999 {
9000 Z_scripterrlog("misc is: %d\n", misc);
9001 return misc <= 0;
9002
9003 }
9004
9005 499943 bool eLeever::animate(int32_t index)
9006 {
9007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 499943 times.
499943 if(switch_hooked) return enemy::animate(index);
9008
2/4
✓ Branch 0 taken 499943 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 499943 times.
499943 if(fallclk||drownclk)
9009 {
9010 return enemy::animate(index);
9011 }
9012
2/2
✓ Branch 0 taken 16506 times.
✓ Branch 1 taken 483437 times.
499943 if(dying)
9013 16506 return Dead(index);
9014
9015
2/2
✓ Branch 0 taken 463097 times.
✓ Branch 1 taken 20340 times.
483437 if(clk==0)
9016 {
9017 20340 removearmos(x,y,ffcactivated);
9018 20340 }
9019
9020
4/4
✓ Branch 0 taken 393192 times.
✓ Branch 1 taken 90245 times.
✓ Branch 2 taken 2529 times.
✓ Branch 3 taken 390663 times.
483437 if(clk>=0 && !slide())
9021 {
9022 // switch(d->misc1)
9023
2/2
✓ Branch 0 taken 156396 times.
✓ Branch 1 taken 234267 times.
390663 switch(dmisc1)
9024 {
9025 case 0: //line of sight
9026 case 2:
9027
7/8
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✓ Branch 2 taken 17136 times.
✓ Branch 3 taken 15898 times.
✓ Branch 4 taken 7088 times.
✓ Branch 5 taken 43977 times.
✓ Branch 6 taken 1832 times.
✓ Branch 7 taken 2915 times.
156396 switch(misc) //is this leever active
9028 {
9029 case -1: //submerged
9030 {
9031
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 67550 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
67550 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 0;
9032
4/4
✓ Branch 0 taken 7609 times.
✓ Branch 1 taken 59941 times.
✓ Branch 2 taken 7582 times.
✓ Branch 3 taken 27 times.
67550 if((dmisc1==2)&&(zc_oldrand()&255))
9033 {
9034 7582 break;
9035 }
9036
9037 59968 int32_t active=0;
9038
9039
2/2
✓ Branch 0 taken 424896 times.
✓ Branch 1 taken 59968 times.
484864 for(int32_t i=0; i<guys.Count(); i++)
9040 {
9041
4/4
✓ Branch 0 taken 348604 times.
✓ Branch 1 taken 76292 times.
✓ Branch 2 taken 229810 times.
✓ Branch 3 taken 118794 times.
424896 if(guys.spr(i)->id==id && (((enemy*)guys.spr(i))->misc>=0))
9042 {
9043 118794 ++active;
9044 118794 }
9045 424896 }
9046
9047
2/2
✓ Branch 0 taken 59147 times.
✓ Branch 1 taken 821 times.
59968 if(active<((dmisc1==2)?1:2))
9048 {
9049 821 misc=0; //activate this one
9050 821 clk3=1; //This needs to be set so that it knows that it's being emerged of its own will and not because it got stunned.
9051 821 }
9052 }
9053 59968 break;
9054
9055 case 0:
9056 {
9057
9058
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 17136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
17136 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9059 {
9060 misc=1;
9061 clk2=0;
9062 }
9063
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 17100 times.
17136 else if (clk3<=0)
9064 {
9065 36 misc = -1;
9066 36 break;
9067 }
9068 17100 int32_t s=0;
9069
9070
2/2
✓ Branch 0 taken 112208 times.
✓ Branch 1 taken 17100 times.
129308 for(int32_t i=0; i<guys.Count(); i++)
9071 {
9072
4/4
✓ Branch 0 taken 74011 times.
✓ Branch 1 taken 38197 times.
✓ Branch 2 taken 71849 times.
✓ Branch 3 taken 2162 times.
112208 if(guys.spr(i)->id==id && ((enemy*)guys.spr(i))->misc==1)
9073 {
9074 2162 ++s;
9075 2162 }
9076 112208 }
9077
9078
2/2
✓ Branch 0 taken 2162 times.
✓ Branch 1 taken 14938 times.
17100 if(s>0)
9079 {
9080 2162 break;
9081 }
9082
9083 14938 int32_t d2=zc_oldrand()&1;
9084
9085
2/2
✓ Branch 0 taken 5336 times.
✓ Branch 1 taken 9602 times.
14938 if(HeroDir()>=left)
9086 {
9087 9602 d2+=2;
9088 9602 }
9089
9090
4/4
✓ Branch 0 taken 14295 times.
✓ Branch 1 taken 643 times.
✓ Branch 2 taken 300 times.
✓ Branch 3 taken 13995 times.
14938 if(canplace(d2) || canplace(d2^1))
9091 {
9092 943 misc=1;
9093 943 clk2=0;
9094 943 clk=0;
9095 943 }
9096 }
9097 14938 break;
9098
9099 case 1:
9100
9101
3/8
✓ Branch 0 taken 14970 times.
✓ Branch 1 taken 928 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 14970 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15898 if(++clk2>16||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>8)) misc=2;
9102
9103 15898 break;
9104
9105 case 2:
9106
9107
3/8
✓ Branch 0 taken 6227 times.
✓ Branch 1 taken 861 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6227 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
7088 if(++clk2>24||(!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk) && clk2>12)) misc=3;
9108
9109 7088 break;
9110
9111 // case 3: if(stunclk) break; if(scored) dir^=1; if(!canmove(dir,false)) misc=4; else move((zfix)(d->step/100.0)); break;
9112 case 3:
9113
9114
5/6
✓ Branch 0 taken 41679 times.
✓ Branch 1 taken 2298 times.
✓ Branch 2 taken 41679 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2066 times.
✓ Branch 5 taken 39613 times.
43977 if(stunclk || frozenclock || watch) break;
9115
9116
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 39534 times.
39613 if(scored) dir^=1;
9117
9118
2/2
✓ Branch 0 taken 211 times.
✓ Branch 1 taken 39402 times.
39613 if(!canmove(dir,false)) misc=4;
9119 39402 else move(zslongToFix(dstep*100));
9120
9121 39613 break;
9122
9123 case 4:
9124
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1832 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1832 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 2;
9125
2/2
✓ Branch 0 taken 1635 times.
✓ Branch 1 taken 197 times.
1832 if(--clk2<=16)
9126 {
9127 197 misc=5;
9128 197 clk=8;
9129 197 }
9130
9131 1832 break;
9132
9133 case 5:
9134
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2915 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2915 if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk)) misc = 1;
9135
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 175 times.
2915 if(--clk2<=0) misc=((dmisc1==2)?-1:0);
9136
9137 2915 break;
9138 } // switch(misc)
9139
9140 156396 break;
9141
9142 default: //random
9143 // step=d->misc3/100.0;
9144
9145 234267 step=zslongToFix(dmisc3*100);
9146
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 234267 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
234267 if (get_qr(qr_LEEVERS_DONT_OBEY_STUN) || (!watch && !stunclk)) ++clk2;
9147 else if (!get_qr(qr_LEEVERS_DONT_OBEY_STUN) && (watch || stunclk))
9148 {
9149 if (clk2 < 48) clk2+=2;
9150 if (clk2 >= 300) clk2-=2;
9151 }
9152
9153
2/2
✓ Branch 0 taken 27519 times.
✓ Branch 1 taken 206748 times.
234267 if(clk2<32) misc=1;
9154
2/2
✓ Branch 0 taken 13816 times.
✓ Branch 1 taken 192932 times.
206748 else if(clk2<48) misc=2;
9155
2/2
✓ Branch 0 taken 140831 times.
✓ Branch 1 taken 52101 times.
192932 else if(clk2<300)
9156 {
9157 /*if(misc==2 && (int32_t)(dmisc3*0.48)%8)
9158 {
9159 fix_coords();
9160 }*/
9161 140831 misc=3;
9162 140831 step = zslongToFix(dstep*100);
9163 140831 }
9164
2/2
✓ Branch 0 taken 4801 times.
✓ Branch 1 taken 47300 times.
52101 else if(clk2<316) misc=2;
9165
2/2
✓ Branch 0 taken 23641 times.
✓ Branch 1 taken 23659 times.
47300 else if(clk2<412) misc=1;
9166
2/2
✓ Branch 0 taken 23490 times.
✓ Branch 1 taken 169 times.
23659 else if(clk2<540)
9167 {
9168 23490 misc=0;
9169 23490 step=0;
9170 23490 }
9171 169 else clk2=0;
9172
9173
2/2
✓ Branch 0 taken 233418 times.
✓ Branch 1 taken 849 times.
234267 if(clk2==48) clk=0;
9174
9175 // variable_walk(d->rate, d->homing, 0);
9176 234267 variable_walk(rate, homing, 0);
9177 234267 } // switch(dmisc1)
9178 390663 }
9179
9180 483437 hxofs=(misc>=2)?0:1000;
9181 483437 return enemy::animate(index);
9182 499943 }
9183
9184 29233 bool eLeever::canplace(int32_t d2)
9185 {
9186 29233 int32_t nx=HeroX();
9187 29233 int32_t ny=HeroY();
9188
9189
2/2
✓ Branch 0 taken 10404 times.
✓ Branch 1 taken 18829 times.
29233 if(d2<left) ny&=0xF0;
9190 18829 else nx&=0xF0;
9191
9192
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 5173 times.
✓ Branch 2 taken 5231 times.
✓ Branch 3 taken 9395 times.
✓ Branch 4 taken 9434 times.
29233 switch(d2)
9193 {
9194 // case up: ny-=((d->misc1==0)?32:48); break;
9195 // case down: ny+=((d->misc1==0)?32:48); if(ny-HeroY()<32) ny+=((d->misc1==0)?16:0); break;
9196 // case left: nx-=((d->misc1==0)?32:48); break;
9197 // case right: nx+=((d->misc1==0)?32:48); if(nx-HeroX()<32) nx+=((d->misc1==0)?16:0); break;
9198 case up:
9199
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 28 times.
5173 ny-=((dmisc1==0||dmisc1==2)?32:48);
9200 5173 break;
9201
9202 case down:
9203
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5200 times.
5231 ny+=((dmisc1==0||dmisc1==2)?32:48);
9204
9205
4/4
✓ Branch 0 taken 2757 times.
✓ Branch 1 taken 2474 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 9 times.
5231 if(ny-HeroY()<32) ny+=((dmisc1==0||dmisc1==2)?16:0);
9206
9207 5231 break;
9208
9209 case left:
9210
2/2
✓ Branch 0 taken 8795 times.
✓ Branch 1 taken 600 times.
9395 nx-=((dmisc1==0||dmisc1==2)?32:48);
9211 9395 break;
9212
9213 case right:
9214
2/2
✓ Branch 0 taken 595 times.
✓ Branch 1 taken 8839 times.
9434 nx+=((dmisc1==0||dmisc1==2)?32:48);
9215
9216
4/4
✓ Branch 0 taken 6054 times.
✓ Branch 1 taken 3380 times.
✓ Branch 2 taken 5499 times.
✓ Branch 3 taken 555 times.
9434 if(nx-HeroX()<32) nx+=((dmisc1==0||dmisc1==2)?16:0);
9217
9218 9434 break;
9219 }
9220
9221
4/4
✓ Branch 0 taken 10020 times.
✓ Branch 1 taken 19213 times.
✓ Branch 2 taken 4483 times.
✓ Branch 3 taken 5537 times.
29233 if(m_walkflag(nx,ny,spw_halfstep, dir)||m_walkflag(nx,ny-8,spw_halfstep, dir)) /*none*/
9222 23696 return false;
9223
9224
2/2
✓ Branch 0 taken 439 times.
✓ Branch 1 taken 5098 times.
5537 if(d2>=left)
9225
4/4
✓ Branch 0 taken 2481 times.
✓ Branch 1 taken 2617 times.
✓ Branch 2 taken 4594 times.
✓ Branch 3 taken 504 times.
5098 if(m_walkflag(HeroX(),HeroY(),spw_halfstep, dir)||m_walkflag(HeroX(),HeroY()-8,spw_halfstep, dir)) /*none*/
9226 4594 return false;
9227
9228 943 x=nx;
9229 943 y=ny;
9230 943 dir=d2^1;
9231 943 return true;
9232 29233 }
9233
9234 500779 void eLeever::draw(BITMAP *dest)
9235 {
9236 // cs=d->cset;
9237 500779 cs=dcset;
9238 500779 update_enemy_frame();
9239
2/4
✓ Branch 0 taken 500779 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 500779 times.
500779 if(!fallclk&&!drownclk)
9240 {
9241
2/2
✓ Branch 0 taken 301145 times.
✓ Branch 1 taken 199634 times.
500779 switch(misc)
9242 {
9243 case -1:
9244 case 0:
9245 199634 return;
9246 }
9247 301145 }
9248
9249 301145 enemy::draw(dest);
9250 500779 }
9251
9252 523 eWallM::eWallM(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9253 523 {
9254 //zprint2("eWallM::eWallM\n");
9255 523 hashero=false;
9256 //nets+1000;
9257 523 SIZEflags = d->SIZEflags;
9258
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9259 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9260 // al_trace("Enemy txsz:%i\n", txsz);
9261
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9262
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9263
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9264
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9265
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9266
1/2
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9267 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9268
1/4
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9270 {
9271 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9272 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9273 }
9274
9275
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 523 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
523 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9276 523 }
9277
9278 321974 bool eWallM::animate(int32_t index)
9279 {
9280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 321974 times.
321974 if(switch_hooked) return enemy::animate(index);
9281
2/4
✓ Branch 0 taken 321974 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 321974 times.
321974 if(fallclk||drownclk)
9282 {
9283 return enemy::animate(index);
9284 }
9285
2/2
✓ Branch 0 taken 6282 times.
✓ Branch 1 taken 315692 times.
321974 if(dying)
9286 6282 return Dead(index);
9287
9288
2/2
✓ Branch 0 taken 295632 times.
✓ Branch 1 taken 20060 times.
315692 if(clk==0)
9289 {
9290 20060 removearmos(x,y,ffcactivated);
9291 20060 }
9292
9293 315692 hxofs=1000;
9294
2/2
✓ Branch 0 taken 81640 times.
✓ Branch 1 taken 234052 times.
315692 if(misc==0) //inside wall, ready to spawn?
9295 {
9296 //zprint2("Wallmaster is ready to spawn, clk is: %d\n",clk);
9297 //zprint2("frame is: %d\n",frame);
9298 //zprint2("wallm_load_clk is: %d\n",wallm_load_clk);
9299
4/4
✓ Branch 0 taken 154566 times.
✓ Branch 1 taken 79486 times.
✓ Branch 2 taken 9024 times.
✓ Branch 3 taken 145542 times.
234052 if(frame-wallm_load_clk>80 && clk>=0)
9300 {
9301 //zprint2("getting wall\n");
9302 145542 int32_t wall=hero_on_wall();
9303 //zprint2("Wallmaster wall is %d\n",wall);
9304 145542 int32_t wallm_cnt=0;
9305
9306
2/2
✓ Branch 0 taken 1108757 times.
✓ Branch 1 taken 145542 times.
1254299 for(int32_t i=0; i<guys.Count(); i++)
9307
2/2
✓ Branch 0 taken 421543 times.
✓ Branch 1 taken 687214 times.
1795971 if(((enemy*)guys.spr(i))->family==eeWALLM)
9308 {
9309 687214 int32_t m=((enemy*)guys.spr(i))->misc;
9310
9311
4/4
✓ Branch 0 taken 32180 times.
✓ Branch 1 taken 655034 times.
✓ Branch 2 taken 20369 times.
✓ Branch 3 taken 11811 times.
687214 if(m && ((enemy*)guys.spr(i))->clk3==(wall^1))
9312 {
9313 11811 ++wallm_cnt;
9314 11811 }
9315 687214 }
9316
9317
2/2
✓ Branch 0 taken 145029 times.
✓ Branch 1 taken 513 times.
145542 if(wall>0)
9318 {
9319 513 --wall;
9320 513 misc=1; //emerging from the wall?
9321 //zprint2("Wallmaster is emerging\n");
9322 513 clk2=0;
9323 513 clk3=wall^1;
9324 513 wallm_load_clk=frame;
9325
9326
2/2
✓ Branch 0 taken 312 times.
✓ Branch 1 taken 201 times.
513 if(wall<=down)
9327 {
9328
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 258 times.
312 if(HeroDir()==left)
9329 54 dir=right;
9330 else
9331 258 dir=left;
9332 312 }
9333 else
9334 {
9335
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 162 times.
201 if(HeroDir()==up)
9336 39 dir=down;
9337 else
9338 162 dir=up;
9339 }
9340
9341
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 152 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 132 times.
✓ Branch 4 taken 69 times.
513 switch(wall)
9342 {
9343 case up:
9344 152 y=0;
9345 152 break;
9346
9347 case down:
9348 160 y=160;
9349 160 break;
9350
9351 case left:
9352 132 x=0;
9353 132 break;
9354
9355 case right:
9356 69 x=240;
9357 69 break;
9358 }
9359
9360 //zprint2("Wallmaster (p1) x is %d\n",x);
9361 //zprint2("Wallmaster (p1) y is %d\n",y);
9362
9363
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 162 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 258 times.
✓ Branch 4 taken 54 times.
513 switch(dir)
9364 {
9365 case up:
9366 162 y=(HeroY()+48-(wallm_cnt&1)*12);
9367 162 flip=wall&1;
9368 162 break;
9369
9370 case down:
9371 39 y=(HeroY()-48+(wallm_cnt&1)*12);
9372 39 flip=((wall&1)^1)+2;
9373 39 break;
9374
9375 case left:
9376 258 x=(HeroX()+48-(wallm_cnt&1)*12);
9377 258 flip=(wall==up?2:0)+1;
9378 258 break;
9379
9380 case right:
9381 54 x=(HeroX()-48+(wallm_cnt&1)*12);
9382 54 flip=(wall==up?2:0);
9383 54 break;
9384 }
9385
9386 //zprint2("Wallmaster (p2) x is %d\n",x);
9387 //zprint2("Wallmaster (p2) y is %d\n",y);
9388 513 }
9389 145542 }
9390 234052 }
9391 else
9392 81640 wallm_crawl();
9393
9394 315692 return enemy::animate(index);
9395 321974 }
9396
9397 81640 void eWallM::wallm_crawl()
9398 {
9399 81640 bool w=watch;
9400 81640 hxofs=0;
9401
9402
2/2
✓ Branch 0 taken 591 times.
✓ Branch 1 taken 81049 times.
81640 if(slide())
9403 {
9404 591 return;
9405 }
9406
9407 // if(dying || watch || (!hashero && stunclk))
9408
6/8
✓ Branch 0 taken 81049 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80760 times.
✓ Branch 3 taken 289 times.
✓ Branch 4 taken 66702 times.
✓ Branch 5 taken 14058 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 66702 times.
81049 if(dying || (!hashero && ( stunclk || frozenclock )))
9409 {
9410 14058 return;
9411 }
9412
9413 66991 watch=false;
9414 66991 ++clk2;
9415 // Misc1: slightly different movement
9416 //zprint2("wallmaster crawl\n");
9417 //zprint2("wallmaster tmpdstep is %d\n",tmpdstep);
9418 66991 float tmpmisc3 = ((40.0/(int32_t)dstep)*40);
9419
9420 //int32_t tmpmisc = int32_t((40.0/dstep)*40);
9421 //zprint2("wallmaster crawl tmpmisc is: %d\n", tmpmisc);
9422 //zprint2("wallmaster crawl tmpmisc4 is: %d\n", tmpmisc4);
9423
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66991 times.
66991 misc=(clk2/(dmisc1==1?40:(int32_t)tmpmisc3))+1;
9424 //zprint2("wallmaster crawl misc is: %d\n", misc);
9425
5/6
✓ Branch 0 taken 5942 times.
✓ Branch 1 taken 61049 times.
✓ Branch 2 taken 4472 times.
✓ Branch 3 taken 1470 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 4472 times.
66991 if(w&&misc>=3&&misc<=5)
9426 {
9427 4472 --clk2;
9428 4472 }
9429
9430
4/4
✓ Branch 0 taken 28236 times.
✓ Branch 1 taken 31313 times.
✓ Branch 2 taken 7328 times.
✓ Branch 3 taken 114 times.
66991 switch(misc)
9431 {
9432 case 1:
9433 case 2:
9434 31313 zc_swap(dir,clk3);
9435 31313 move(step);
9436 31313 zc_swap(dir,clk3);
9437 31313 break;
9438
9439 case 3:
9440 case 4:
9441 case 5:
9442
2/2
✓ Branch 0 taken 4472 times.
✓ Branch 1 taken 23764 times.
28236 if(w)
9443 {
9444 4472 watch=w;
9445 4472 return;
9446 }
9447
9448 23764 move(step);
9449 23764 break;
9450
9451 case 6:
9452 case 7:
9453 7328 zc_swap(dir,clk3);
9454 7328 dir^=1;
9455 7328 move(step);
9456 7328 dir^=1;
9457 7328 zc_swap(dir,clk3);
9458 7328 break;
9459
9460 default:
9461 114 misc=0;
9462 114 break;
9463 }
9464
9465 62519 watch=w;
9466 81640 }
9467
9468 3 void eWallM::grabhero()
9469 {
9470 3 hashero=true;
9471 3 superman=1;
9472 3 }
9473
9474 322782 void eWallM::draw(BITMAP *dest)
9475 {
9476 322782 dummy_bool[1]=hashero;
9477 322782 update_enemy_frame();
9478
9479
4/6
✓ Branch 0 taken 234569 times.
✓ Branch 1 taken 88213 times.
✓ Branch 2 taken 234569 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 234569 times.
322782 if(misc>0 || fallclk||drownclk)
9480 {
9481 88213 masked_draw(dest,16,playing_field_offset+16,224,144);
9482 88213 }
9483
9484 // enemy::draw(dest);
9485 // tile = clk&8 ? 128:129;
9486 322782 }
9487
9488 bool eWallM::isSubmerged() const
9489 {
9490 return ( !misc );
9491 }
9492
9493 742 eTrap::eTrap(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9494 742 {
9495
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 ox=x; //original x
9496
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 oy=y; //original y
9497
3/4
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 676 times.
742 if(get_qr(qr_TRAPPOSFIX))
9498 {
9499
3/6
✓ Branch 0 taken 66 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 66 times.
✓ Branch 4 taken 66 times.
✗ Branch 5 not taken.
66 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9500 66 }
9501
9502 742 mainguy=false;
9503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9504 //nets+420;
9505 742 dummy_int[1]=0;
9506 742 SIZEflags = d->SIZEflags;
9507
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9508 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9509 // al_trace("Enemy txsz:%i\n", txsz);
9510
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9511
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9512
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9513
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9514
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9515
1/2
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9516 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9517
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9519 {
9520 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9521 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9522 }
9523
9524
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 742 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
742 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9525 742 }
9526
9527 534456 bool eTrap::animate(int32_t index)
9528 {
9529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 534456 times.
534456 if(switch_hooked) return enemy::animate(index);
9530
2/4
✓ Branch 0 taken 534456 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 534456 times.
534456 if(fallclk||drownclk) return enemy::animate(index);
9531
2/2
✓ Branch 0 taken 524072 times.
✓ Branch 1 taken 10384 times.
534456 if(clk<0)
9532 10384 return enemy::animate(index);
9533
9534
2/2
✓ Branch 0 taken 490954 times.
✓ Branch 1 taken 33118 times.
524072 if(clk==0)
9535 {
9536 33118 removearmos(x,y,ffcactivated);
9537 33118 }
9538
9539
2/2
✓ Branch 0 taken 142952 times.
✓ Branch 1 taken 381120 times.
524072 if(misc==0) // waiting
9540 {
9541 381120 ox = x;
9542 381120 oy = y;
9543 double _MSVC2022_tmp1, _MSVC2022_tmp2;
9544 381120 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
9545
9546
4/4
✓ Branch 0 taken 127495 times.
✓ Branch 1 taken 253625 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 53982 times.
381120 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
9547 {
9548 53982 dir=down;
9549 53982 }
9550
4/4
✓ Branch 0 taken 220423 times.
✓ Branch 1 taken 106715 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 146910 times.
327138 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
9551 {
9552 146910 dir=right;
9553 146910 }
9554
4/4
✓ Branch 0 taken 112988 times.
✓ Branch 1 taken 67240 times.
✓ Branch 2 taken 73513 times.
✓ Branch 3 taken 39475 times.
180228 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
9555 {
9556 39475 dir=up;
9557 39475 }
9558 else
9559 {
9560 140753 dir=left;
9561 }
9562
9563 381120 int32_t d2=lined_up(15,true);
9564
9565
4/4
✓ Branch 0 taken 135666 times.
✓ Branch 1 taken 245454 times.
✓ Branch 2 taken 684811 times.
✓ Branch 3 taken 303691 times.
615292 if(((d2<left || d2 > right) && (dmisc1==1)) ||
9566
2/2
✓ Branch 0 taken 129243 times.
✓ Branch 1 taken 174448 times.
303691 ((d2>down) && (dmisc1==2)) ||
9567
2/2
✓ Branch 0 taken 118337 times.
✓ Branch 1 taken 70965 times.
174448 ((d2>right) && (!dmisc1)) ||
9568
2/2
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
189302 ((d2<l_up) && (dmisc1==4)) ||
9569
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 168538 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
65634 ((d2!=r_up) && (d2!=l_down) && (dmisc1==6)) ||
9570
3/4
✓ Branch 0 taken 234172 times.
✓ Branch 1 taken 65634 times.
✓ Branch 2 taken 234172 times.
✗ Branch 3 not taken.
168538 ((d2!=l_up) && (d2!=r_down) && (dmisc1==8)))
9571 {
9572 1516570 d2=-1;
9573 1516570 }
9574
9575
4/4
✓ Branch 0 taken 11339 times.
✓ Branch 1 taken 201243 times.
✓ Branch 2 taken 10273 times.
✓ Branch 3 taken 1066 times.
212582 if(d2!=-1 && trapmove(d2))
9576 {
9577 1066 dir=d2;
9578 1066 misc=1;
9579 1066 clk2=(dir==down)?3:0;
9580 1066 }
9581 212582 }
9582
9583
2/2
✓ Branch 0 taken 316873 times.
✓ Branch 1 taken 38661 times.
355534 if(misc==1) // charging
9584 {
9585 38661 clk2=(clk2+1)&3;
9586 38661 step=(clk2==3)?1:2;
9587
9588
4/4
✓ Branch 0 taken 38531 times.
✓ Branch 1 taken 130 times.
✓ Branch 2 taken 860 times.
✓ Branch 3 taken 37671 times.
38661 if(!trapmove(dir) || clip())
9589 {
9590 990 misc=2;
9591
9592
1/2
✓ Branch 0 taken 990 times.
✗ Branch 1 not taken.
990 if(dir<l_up)
9593 {
9594 990 dir=dir^1;
9595 990 }
9596 else
9597 {
9598 dir=dir^3;
9599 }
9600 990 }
9601 else
9602 {
9603 37671 sprite::move(step);
9604 }
9605 38661 }
9606
9607
2/2
✓ Branch 0 taken 249187 times.
✓ Branch 1 taken 106347 times.
355534 if(misc==2) // retreating
9608 {
9609 106347 step=(++clk2&1)?1:0;
9610
9611
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 17320 times.
✓ Branch 2 taken 39848 times.
✓ Branch 3 taken 11903 times.
✓ Branch 4 taken 37276 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
106347 switch(dir)
9612 {
9613 case up:
9614
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 17181 times.
17320 if(int32_t(y)<=oy) goto trap_rest;
9615 17181 else sprite::move(step);
9616
9617 17181 break;
9618
9619 case left:
9620
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 39620 times.
39848 if(int32_t(x)<=ox) goto trap_rest;
9621 39620 else sprite::move(step);
9622
9623 39620 break;
9624
9625 case down:
9626
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 11791 times.
11903 if(int32_t(y)>=oy) goto trap_rest;
9627 11791 else sprite::move(step);
9628
9629 11791 break;
9630
9631 case right:
9632
2/2
✓ Branch 0 taken 227 times.
✓ Branch 1 taken 37049 times.
37276 if(int32_t(x)>=ox) goto trap_rest;
9633 37049 else sprite::move(step);
9634
9635 37049 break;
9636
9637 case l_up:
9638 if(int32_t(x)<=ox && int32_t(y)<=oy) goto trap_rest;
9639 else sprite::move(step);
9640
9641 break;
9642
9643 case r_up:
9644 if(int32_t(x)>=ox && int32_t(y)<=oy) goto trap_rest;
9645 else sprite::move(step);
9646
9647 break;
9648
9649 case l_down:
9650 if(int32_t(x)<=ox && int32_t(y)>=oy) goto trap_rest;
9651 else sprite::move(step);
9652
9653 break;
9654
9655 case r_down:
9656 if(int32_t(x)>=ox && int32_t(y)>=oy) goto trap_rest;
9657 else sprite::move(step);
9658
9659 break;
9660 trap_rest:
9661 {
9662 706 x=ox;
9663 706 y=oy;
9664 706 misc=0;
9665 }
9666 706 }
9667 106347 }
9668
9669 355534 return enemy::animate(index);
9670 365918 }
9671
9672 50000 bool eTrap::trapmove(int32_t ndir)
9673 {
9674
2/2
✓ Branch 0 taken 35733 times.
✓ Branch 1 taken 14267 times.
50000 if(get_qr(qr_MEANTRAPS))
9675 {
9676
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 34393 times.
35733 if(tmpscr->flags2&fFLOATTRAPS)
9677 1340 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9678
9679 34393 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9680 }
9681
9682
6/6
✓ Branch 0 taken 6244 times.
✓ Branch 1 taken 8023 times.
✓ Branch 2 taken 4374 times.
✓ Branch 3 taken 1870 times.
✓ Branch 4 taken 1608 times.
✓ Branch 5 taken 2766 times.
14267 if(oy==80 && !(ndir==left || ndir == right))
9683 2766 return false;
9684
9685
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 11501 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
11501 if(ox==128 && !(ndir==up || ndir==down))
9686 return false;
9687
9688
3/4
✓ Branch 0 taken 4333 times.
✓ Branch 1 taken 7168 times.
✓ Branch 2 taken 4333 times.
✗ Branch 3 not taken.
11501 if(oy<80 && ndir==up)
9689 return false;
9690
9691
3/4
✓ Branch 0 taken 3690 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 3690 times.
✗ Branch 3 not taken.
11501 if(oy>80 && ndir==down)
9692 return false;
9693
9694
4/4
✓ Branch 0 taken 5854 times.
✓ Branch 1 taken 5647 times.
✓ Branch 2 taken 5136 times.
✓ Branch 3 taken 718 times.
11501 if(ox<128 && ndir==left)
9695 718 return false;
9696
9697
4/4
✓ Branch 0 taken 5647 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 5159 times.
✓ Branch 3 taken 488 times.
10783 if(ox>128 && ndir==right)
9698 488 return false;
9699
9700
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 2207 times.
✓ Branch 3 taken 2929 times.
✓ Branch 4 taken 2207 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy<80 && ndir==l_up)
9701 return false;
9702
9703
5/6
✓ Branch 0 taken 5136 times.
✓ Branch 1 taken 5159 times.
✓ Branch 2 taken 1809 times.
✓ Branch 3 taken 3327 times.
✓ Branch 4 taken 1809 times.
✗ Branch 5 not taken.
10295 if(ox<128 && oy>80 && ndir==l_down)
9704 return false;
9705
9706
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 2126 times.
✓ Branch 3 taken 3033 times.
✓ Branch 4 taken 2126 times.
✗ Branch 5 not taken.
10295 if(ox>128 && oy<80 && ndir==r_up)
9707 return false;
9708
9709
5/6
✓ Branch 0 taken 5159 times.
✓ Branch 1 taken 5136 times.
✓ Branch 2 taken 1881 times.
✓ Branch 3 taken 3278 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1881 times.
10295 if(ox>128 && oy>80 && ndir==r_down)
9710 return false;
9711
9712 10295 return true;
9713 50000 }
9714
9715 38531 bool eTrap::clip()
9716 {
9717
2/2
✓ Branch 0 taken 33513 times.
✓ Branch 1 taken 5018 times.
38531 if(get_qr(qr_MEANPLACEDTRAPS))
9718 {
9719
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
✓ Branch 2 taken 1926 times.
✓ Branch 3 taken 985 times.
✓ Branch 4 taken 1377 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5018 switch(dir)
9720 {
9721 case up:
9722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 730 times.
730 if(y<=0) return true;
9723
9724 730 break;
9725
9726 case down:
9727
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1926 times.
1926 if(y>=160) return true;
9728
9729 1926 break;
9730
9731 case left:
9732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 985 times.
985 if(x<=0) return true;
9733
9734 985 break;
9735
9736 case right:
9737
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1377 times.
1377 if(x>=240) return true;
9738
9739 1377 break;
9740
9741 case l_up:
9742 if(y<=0||x<=0) return true;
9743
9744 break;
9745
9746 case l_down:
9747 if(y>=160||x<=0) return true;
9748
9749 break;
9750
9751 case r_up:
9752 if(y<=0||x>=240) return true;
9753
9754 break;
9755
9756 case r_down:
9757 if(y>=160||x>=240) return true;
9758
9759 break;
9760 }
9761
9762 5018 return false;
9763 }
9764 else
9765 {
9766
4/9
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
✓ Branch 2 taken 4135 times.
✓ Branch 3 taken 12605 times.
✓ Branch 4 taken 13028 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
33513 switch(dir)
9767 {
9768 case up:
9769
4/4
✓ Branch 0 taken 3691 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 3546 times.
✓ Branch 3 taken 145 times.
3745 if(oy>80 && y<=86) return true;
9770
9771 3600 break;
9772
9773 case down:
9774
4/4
✓ Branch 0 taken 4054 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 3903 times.
✓ Branch 3 taken 151 times.
4135 if(oy<80 && y>=80) return true;
9775
9776 3984 break;
9777
9778 case left:
9779
4/4
✓ Branch 0 taken 12515 times.
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 12236 times.
✓ Branch 3 taken 279 times.
12605 if(ox>128 && x<=124) return true;
9780
9781 12326 break;
9782
9783 case right:
9784
3/4
✓ Branch 0 taken 13028 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12743 times.
✓ Branch 3 taken 285 times.
13028 if(ox<120 && x>=116) return true;
9785
9786 12743 break;
9787
9788 case l_up:
9789 if(oy>80 && y<=86 && ox>128 && x<=124) return true;
9790
9791 break;
9792
9793 case l_down:
9794 if(oy<80 && y>=80 && ox>128 && x<=124) return true;
9795
9796 break;
9797
9798 case r_up:
9799 if(oy>80 && y<=86 && ox<120 && x>=116) return true;
9800
9801 break;
9802
9803 case r_down:
9804 if(oy<80 && y>=80 && ox<120 && x>=116) return true;
9805
9806 break;
9807 }
9808
9809 32653 return false;
9810 }
9811 38531 }
9812
9813 537872 void eTrap::draw(BITMAP *dest)
9814 {
9815 537872 update_enemy_frame();
9816 537872 enemy::draw(dest);
9817 537872 }
9818
9819 2407 int32_t eTrap::takehit(weapon*,weapon*)
9820 {
9821 2407 return 0;
9822 }
9823
9824 147 eTrap2::eTrap2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9825 147 {
9826 147 lasthit=-1;
9827 147 lasthitclk=0;
9828 147 mainguy=false;
9829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
9830
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 step=2;
9831
3/6
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if(dmisc1==1 || (dmisc1==0 && zc_oldrand()&2))
9832 {
9833
2/4
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
67 dir=(x<=112)?right:left;
9834 67 }
9835 else
9836 {
9837
2/4
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
80 dir=(y<=72)?down:up;
9838 }
9839
9840
2/4
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
147 if(get_qr(qr_TRAPPOSFIX))
9841 {
9842 yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
9843 }
9844
9845 //nets+((id==eTRAP_LR)?540:520);
9846 147 dummy_int[1]=0;
9847 147 SIZEflags = d->SIZEflags;
9848
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
9849 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
9850 // al_trace("Enemy txsz:%i\n", txsz);
9851
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
9852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
9853
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
9854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
9855
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9856
1/2
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9857 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
9858
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
9859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
9860 {
9861 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
9862 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
9863 }
9864
9865
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
147 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
9866 147 }
9867
9868 85467 bool eTrap2::animate(int32_t index)
9869 {
9870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 85467 times.
85467 if(switch_hooked) return enemy::animate(index);
9871
2/4
✓ Branch 0 taken 85467 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 85467 times.
85467 if(fallclk||drownclk) return enemy::animate(index);
9872
2/2
✓ Branch 0 taken 83409 times.
✓ Branch 1 taken 2058 times.
85467 if(clk<0)
9873 2058 return enemy::animate(index);
9874
9875
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 78120 times.
83409 if(clk==0)
9876 {
9877 5289 removearmos(x,y,ffcactivated);
9878 5289 }
9879
9880
2/2
✓ Branch 0 taken 79017 times.
✓ Branch 1 taken 4392 times.
83409 if(!get_qr(qr_PHANTOMPLACEDTRAPS))
9881 {
9882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4392 times.
4392 if(lasthitclk>0)
9883 {
9884 --lasthitclk;
9885 }
9886 else
9887 {
9888 4392 lasthit=-1;
9889 }
9890
9891 4392 bool hitenemy=false;
9892
9893
2/2
✓ Branch 0 taken 57096 times.
✓ Branch 1 taken 4392 times.
61488 for(int32_t j=0; j<guys.Count(); j++)
9894 {
9895
3/4
✓ Branch 0 taken 52704 times.
✓ Branch 1 taken 4392 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52704 times.
57096 if((j!=index) && (lasthit!=j))
9896 {
9897
1/2
✓ Branch 0 taken 52704 times.
✗ Branch 1 not taken.
52704 if(hit(guys.spr(j)))
9898 {
9899 lasthit=j;
9900 lasthitclk=10;
9901 hitenemy=true;
9902 guys.spr(j)->lasthit=index;
9903 guys.spr(j)->lasthitclk=10;
9904 // guys.spr(j)->dir=guys.spr(j)->dir^1;
9905 }
9906 52704 }
9907 57096 }
9908
9909
4/6
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 4344 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 4344 times.
4392 if(!trapmove(dir) || clip() || hitenemy)
9910 {
9911
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
48 if(!trapmove(dir) || clip())
9912 {
9913 48 lasthit=-1;
9914 48 lasthitclk=0;
9915 48 }
9916
9917
1/2
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
48 if(get_qr(qr_MORESOUNDS))
9918 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9919
9920 48 dir=dir^1;
9921 48 }
9922
9923 4392 sprite::move(step);
9924 4392 }
9925 else
9926 {
9927
3/4
✓ Branch 0 taken 77234 times.
✓ Branch 1 taken 1783 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77234 times.
79017 if(!trapmove(dir) || clip())
9928 {
9929
1/2
✓ Branch 0 taken 1783 times.
✗ Branch 1 not taken.
1783 if(get_qr(qr_MORESOUNDS))
9930 sfx(WAV_ZN1TAP,pan(int32_t(x)));
9931
9932 1783 dir=dir^1;
9933 1783 }
9934
9935 79017 sprite::move(step);
9936 }
9937
9938 83409 return enemy::animate(index);
9939 85467 }
9940
9941 83457 bool eTrap2::trapmove(int32_t ndir)
9942 {
9943
2/2
✓ Branch 0 taken 1878 times.
✓ Branch 1 taken 81579 times.
83457 if(tmpscr->flags2&fFLOATTRAPS)
9944 1878 return canmove(ndir,(zfix)1,spw_floater, 0, 0, 15, 15,false);
9945
9946 81579 return canmove(ndir,(zfix)1,spw_water, 0, 0, 15, 15,false);
9947 83457 }
9948
9949 81578 bool eTrap2::clip()
9950 {
9951
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 23387 times.
✓ Branch 2 taken 23376 times.
✓ Branch 3 taken 17291 times.
✓ Branch 4 taken 17524 times.
81578 switch(dir)
9952 {
9953 case up:
9954
1/2
✓ Branch 0 taken 23387 times.
✗ Branch 1 not taken.
23387 if(y<=0) return true;
9955
9956 23387 break;
9957
9958 case down:
9959
1/2
✓ Branch 0 taken 23376 times.
✗ Branch 1 not taken.
23376 if(y>=160) return true;
9960
9961 23376 break;
9962
9963 case left:
9964
1/2
✓ Branch 0 taken 17291 times.
✗ Branch 1 not taken.
17291 if(x<=0) return true;
9965
9966 17291 break;
9967
9968 case right:
9969
1/2
✓ Branch 0 taken 17524 times.
✗ Branch 1 not taken.
17524 if(x>=240) return true;
9970
9971 17524 break;
9972 }
9973
9974 81578 return false;
9975 81578 }
9976
9977 85478 void eTrap2::draw(BITMAP *dest)
9978 {
9979 85478 update_enemy_frame();
9980 85478 enemy::draw(dest);
9981 85478 }
9982
9983 531 int32_t eTrap2::takehit(weapon*,weapon*)
9984 {
9985 531 return 0;
9986 }
9987
9988 226 eRock::eRock(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
9989 226 {
9990 //do not show "enemy appering" anim -DD
9991 226 clk=0;
9992 226 mainguy=false;
9993 226 clk2=-14;
9994 //Enemy Editor Size Tab
9995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
9996 226 else hxofs = -2;
9997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
9998 226 else hyofs = -2;
9999
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10000 226 else hit_width = 20;
10001
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10002 226 else hit_height=20;
10003
10004
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10005
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10007
1/4
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10009 {
10010 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10011 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10012 }
10013
10014
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 226 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
226 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10015 //nets+1640;
10016 226 }
10017
10018 79036 bool eRock::animate(int32_t index)
10019 {
10020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(switch_hooked) return enemy::animate(index);
10021
2/4
✓ Branch 0 taken 79036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 79036 times.
79036 if(fallclk||drownclk) return enemy::animate(index);
10022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79036 times.
79036 if(dying)
10023 return Dead(index);
10024
10025
2/2
✓ Branch 0 taken 73519 times.
✓ Branch 1 taken 5517 times.
79036 if(clk==0)
10026 {
10027 5517 removearmos(x,y,ffcactivated);
10028 5517 }
10029
10030
2/2
✓ Branch 0 taken 78591 times.
✓ Branch 1 taken 445 times.
79036 if(++clk2==0) // start it
10031 {
10032 445 x=zc_oldrand()&0xF0;
10033 445 y=0;
10034 445 clk3=0;
10035 445 clk2=zc_oldrand()&15;
10036 445 }
10037
10038
2/2
✓ Branch 0 taken 14660 times.
✓ Branch 1 taken 64376 times.
79036 if(clk2>16) // move it
10039 {
10040
2/2
✓ Branch 0 taken 62155 times.
✓ Branch 1 taken 2221 times.
64376 if(clk3<=0) // start bounce
10041 {
10042 2221 dir=zc_oldrand()&1;
10043
10044
2/2
✓ Branch 0 taken 1966 times.
✓ Branch 1 taken 255 times.
2221 if(x<32) dir=1;
10045
10046
2/2
✓ Branch 0 taken 2040 times.
✓ Branch 1 taken 181 times.
2221 if(x>208) dir=0;
10047 2221 }
10048
10049
2/2
✓ Branch 0 taken 62303 times.
✓ Branch 1 taken 2073 times.
64376 if(clk3<13+16)
10050 {
10051 62303 x += dir ? 1 : -1; //right, left
10052 62303 dummy_int[1]=dir;
10053
10054
2/2
✓ Branch 0 taken 4436 times.
✓ Branch 1 taken 57867 times.
62303 if(clk3<2)
10055 {
10056 4436 y-=2; //up
10057 4436 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10058 4436 }
10059
2/2
✓ Branch 0 taken 6614 times.
✓ Branch 1 taken 51253 times.
57867 else if(clk3<5)
10060 {
10061 6614 y--; //up
10062 6614 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10063 6614 }
10064
2/2
✓ Branch 0 taken 6569 times.
✓ Branch 1 taken 44684 times.
51253 else if(clk3<8)
10065 {
10066 6569 dummy_int[2]=(dummy_int[1]==1)?right:left;
10067 6569 }
10068
2/2
✓ Branch 0 taken 6518 times.
✓ Branch 1 taken 38166 times.
44684 else if(clk3<11)
10069 {
10070 6518 y++; //down
10071 6518 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10072 6518 }
10073 else
10074 {
10075 38166 y+=2; //down
10076 38166 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10077 }
10078
10079 62303 ++clk3;
10080 62303 }
10081
2/2
✓ Branch 0 taken 1793 times.
✓ Branch 1 taken 280 times.
2073 else if(y<176)
10082 1793 clk3=0; // next bounce
10083 else
10084 280 clk2 = -(zc_oldrand()&63); // back to top
10085 64376 }
10086
10087 79036 return enemy::animate(index);
10088 79036 }
10089
10090 21684 void eRock::drawshadow(BITMAP *dest, bool translucent)
10091 {
10092
2/2
✓ Branch 0 taken 2969 times.
✓ Branch 1 taken 18715 times.
21684 if(clk2>=0)
10093 {
10094 18715 int32_t tempy=yofs;
10095 18715 flip = 0;
10096 18715 int32_t fdiv = frate/4;
10097
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
10098
1/2
✓ Branch 0 taken 18715 times.
✗ Branch 1 not taken.
18715 int32_t f2=get_qr(qr_NEWENEMYTILES)?
10099 18715 efrate:((clk>=(frate>>1))?1:0);
10100 18715 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10101
10102 18715 yofs+=8;
10103
6/6
✓ Branch 0 taken 8758 times.
✓ Branch 1 taken 9957 times.
✓ Branch 2 taken 16513 times.
✓ Branch 3 taken 2202 times.
✓ Branch 4 taken 8135 times.
✓ Branch 5 taken 8378 times.
18715 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18715 times.
18715 if(!shadow_overpit(this))
10105 18715 enemy::drawshadow(dest, translucent);
10106 18715 yofs=tempy;
10107 18715 }
10108 21684 }
10109
10110 79097 void eRock::draw(BITMAP *dest)
10111 {
10112
4/6
✓ Branch 0 taken 10969 times.
✓ Branch 1 taken 68128 times.
✓ Branch 2 taken 10969 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10969 times.
79097 if(clk2>=0 || fallclk||drownclk)
10113 {
10114 68128 int32_t tempdir=dir;
10115 68128 dir=dummy_int[2];
10116 68128 update_enemy_frame();
10117 68128 enemy::draw(dest);
10118 68128 dir=tempdir;
10119 68128 }
10120 79097 }
10121
10122 859 int32_t eRock::takehit(weapon*,weapon*)
10123 {
10124 859 return 0;
10125 }
10126
10127 30 eBoulder::eBoulder(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10128 30 {
10129 30 clk=0;
10130 30 mainguy=false;
10131 30 clk2=-14;
10132
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10133 30 else hxofs= -10;
10134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10135 30 else hyofs=-10;
10136
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10137 30 else hit_width=36;
10138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
10139 30 else hit_height=36;
10140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
10141 30 else hzsz=16; //can't be jumped
10142
10143
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10144
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10145
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( ((d->SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
10146
1/4
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
10147
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10148 {
10149 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10150 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10151 }
10152
10153
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30 if ( (d->SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
10154 //nets+1680;
10155 30 }
10156
10157 4440 bool eBoulder::animate(int32_t index)
10158 {
10159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(switch_hooked) return enemy::animate(index);
10160
2/4
✓ Branch 0 taken 4440 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4440 times.
4440 if(fallclk||drownclk) return enemy::animate(index);
10161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
4440 if(dying)
10162 return Dead(index);
10163
10164
2/2
✓ Branch 0 taken 4150 times.
✓ Branch 1 taken 290 times.
4440 if(clk==0)
10165 {
10166 290 removearmos(x,y,ffcactivated);
10167 290 }
10168
10169 zfix *vert;
10170
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4440 times.
✓ Branch 2 taken 4440 times.
✗ Branch 3 not taken.
4440 vert = (moveflags & FLAG_USE_FAKE_Z) ? &fakez : get_qr(qr_ENEMIESZAXIS) ? &z : &y;
10171
10172
2/2
✓ Branch 0 taken 4408 times.
✓ Branch 1 taken 32 times.
4440 if(++clk2==0) // start it
10173 {
10174 32 x=zc_oldrand()&0xF0;
10175 32 y=-32;
10176 32 clk3=0;
10177 32 clk2=zc_oldrand()&15;
10178 32 }
10179
10180
2/2
✓ Branch 0 taken 842 times.
✓ Branch 1 taken 3598 times.
4440 if(clk2>16) // move it
10181 {
10182
2/2
✓ Branch 0 taken 3467 times.
✓ Branch 1 taken 131 times.
3598 if(clk3<=0) // start bounce
10183 {
10184 131 dir=zc_oldrand()&1;
10185
10186
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 10 times.
131 if(x<32) dir=1;
10187
10188
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(x>208) dir=0;
10189 131 }
10190
10191
2/2
✓ Branch 0 taken 3487 times.
✓ Branch 1 taken 111 times.
3598 if(clk3<13+16)
10192 {
10193 3487 x += dir ? 1 : -1; //right, left
10194 3487 dummy_int[1]=dir;
10195
10196
2/2
✓ Branch 0 taken 261 times.
✓ Branch 1 taken 3226 times.
3487 if(clk3<2)
10197 {
10198 261 y-=2; //up
10199 261 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10200 261 }
10201
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 2844 times.
3226 else if(clk3<5)
10202 {
10203 382 y--; //up
10204 382 dummy_int[2]=(dummy_int[1]==1)?r_up:l_up;
10205 382 }
10206
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 2468 times.
2844 else if(clk3<8)
10207 {
10208 376 dummy_int[2]=(dummy_int[1]==1)?right:left;
10209 376 }
10210
2/2
✓ Branch 0 taken 367 times.
✓ Branch 1 taken 2101 times.
2468 else if(clk3<11)
10211 {
10212 367 y++; //down
10213 367 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10214 367 }
10215 else
10216 {
10217 2101 y+=2; //down
10218 2101 dummy_int[2]=(dummy_int[1]==1)?r_down:l_down;
10219 }
10220
10221 3487 ++clk3;
10222 3487 }
10223
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 10 times.
111 else if(y<176)
10224 101 clk3=0; // next bounce
10225 else
10226 10 clk2 = -(zc_oldrand()&63); // back to top
10227 3598 }
10228
10229 4440 return enemy::animate(index);
10230 4440 }
10231
10232 4440 void eBoulder::drawshadow(BITMAP *dest, bool translucent)
10233 {
10234
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
4440 if(clk2>=0)
10235 {
10236 3868 int32_t tempy=yofs;
10237 3868 flip = 0;
10238 3868 int32_t f2=((clk<<2)/frate)<<1;
10239 3868 shadowtile = wpnsbuf[spr_shadow].tile+f2;
10240
6/6
✓ Branch 0 taken 1729 times.
✓ Branch 1 taken 2139 times.
✓ Branch 2 taken 3356 times.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 1618 times.
✓ Branch 5 taken 1738 times.
3868 yofs+=zc_max(0,zc_min(29-clk3,clk3));
10241
10242 3868 yofs+=8;
10243 3868 xofs-=8;
10244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10245 3868 enemy::drawshadow(dest, translucent);
10246 3868 xofs+=16;
10247 3868 ++shadowtile;
10248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10249 3868 enemy::drawshadow(dest, translucent);
10250 3868 yofs+=16;
10251 3868 shadowtile+=20;
10252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10253 3868 enemy::drawshadow(dest, translucent);
10254 3868 xofs-=16;
10255 3868 --shadowtile;
10256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3868 times.
3868 if(!shadow_overpit(this))
10257 3868 enemy::drawshadow(dest, translucent);
10258 3868 xofs+=8;
10259 3868 yofs=tempy;
10260 3868 }
10261 4440 }
10262
10263 4440 void eBoulder::draw(BITMAP *dest)
10264 {
10265
4/6
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 3868 times.
✓ Branch 2 taken 572 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 572 times.
4440 if(clk2>=0 || fallclk||drownclk)
10266 {
10267 3868 int32_t tempdir=dir;
10268 3868 dir=dummy_int[2];
10269 3868 update_enemy_frame();
10270 3868 dir=tempdir;
10271 3868 xofs-=8;
10272 3868 yofs-=8;
10273 3868 drawblock(dest,15);
10274 3868 xofs+=8;
10275 3868 yofs+=8;
10276 // enemy::draw(dest);
10277 3868 }
10278 4440 }
10279
10280 int32_t eBoulder::takehit(weapon*,weapon*)
10281 {
10282 return 0;
10283 }
10284
10285 2257 eProjectile::eProjectile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk),
10286
3/4
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 514 times.
✓ Branch 3 taken 1743 times.
2257 minRange(get_qr(qr_BROKENSTATUES) ? 0 : Clk)
10287 2257 {
10288 /* fixing
10289 hp=1;
10290 */
10291 2257 mainguy=false;
10292
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10293 2257 hclk=clk; // the "no fire" range
10294 2257 clk=0;
10295 2257 clk3=96;
10296 2257 timer=0;
10297
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 2250 times.
2257 if(o_tile==0)
10298 {
10299 2250 superman=1;
10300 2250 hxofs=1000;
10301 2250 }
10302 2257 SIZEflags = d->SIZEflags;
10303
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10304 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10305 // al_trace("Enemy txsz:%i\n", txsz);
10306
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10307
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10308
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10309
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10310
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10311
1/2
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10312 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10313
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10315 {
10316 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10317 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10318 }
10319
10320
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2257 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2257 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10321 2257 }
10322
10323 1551984 bool eProjectile::animate(int32_t index)
10324 {
10325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1551984 times.
1551984 if(switch_hooked) return enemy::animate(index);
10326
2/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1551984 times.
1551984 if(fallclk||drownclk) return enemy::animate(index);
10327
2/2
✓ Branch 0 taken 1544504 times.
✓ Branch 1 taken 7480 times.
1551984 if(clk==0)
10328 {
10329 7480 removearmos(x,y,ffcactivated);
10330 7480 }
10331
10332 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10333 1551984 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10334
10335
4/4
✓ Branch 0 taken 507924 times.
✓ Branch 1 taken 1044060 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 229115 times.
1551984 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10336 {
10337 229115 dir=down;
10338 229115 }
10339
4/4
✓ Branch 0 taken 850200 times.
✓ Branch 1 taken 472669 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 571391 times.
1322869 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10340 {
10341 571391 dir=right;
10342 571391 }
10343
4/4
✓ Branch 0 taken 519744 times.
✓ Branch 1 taken 231734 times.
✓ Branch 2 taken 278809 times.
✓ Branch 3 taken 240935 times.
751478 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/4)))
10344 {
10345 240935 dir=up;
10346 240935 }
10347 else
10348 {
10349 510543 dir=left;
10350 }
10351
10352
3/4
✓ Branch 0 taken 1551984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 812552 times.
✓ Branch 3 taken 739432 times.
1551984 if(!stunclk && ++clk3>80)
10353 {
10354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 739432 times.
739432 if(dmisc1==9) // Breath type
10355 {
10356 if(timer==0)
10357 {
10358 unsigned r=zc_oldrand();
10359
10360 if(!(r&63))
10361 {
10362 timer=zc_oldrand()%50+50;
10363 }
10364 }
10365
10366 if(timer>0)
10367 {
10368 if(timer%4==0)
10369 {
10370 FireBreath(false);
10371 }
10372
10373 if(--timer==0)
10374 {
10375 clk3=0;
10376 }
10377 }
10378 }
10379
10380 else // Not breath type
10381 {
10382 739432 unsigned r=zc_oldrand();
10383
10384
4/4
✓ Branch 0 taken 11616 times.
✓ Branch 1 taken 727816 times.
✓ Branch 2 taken 839 times.
✓ Branch 3 taken 10777 times.
739432 if(!(r&63) && !HeroInRange(minRange))
10385 {
10386 10777 FireWeapon();
10387
10388
3/4
✓ Branch 0 taken 8406 times.
✓ Branch 1 taken 2371 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
10838 if(get_qr(qr_BROKENSTATUES)==0 &&
10389
3/4
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 8345 times.
✓ Branch 2 taken 61 times.
✗ Branch 3 not taken.
8406 ((wpn==ewFireball || wpn==ewFireball2) || dmisc1==e1tNORMAL))
10390 {
10391
2/2
✓ Branch 0 taken 7924 times.
✓ Branch 1 taken 482 times.
8406 if(!((r>>7)&15))
10392 {
10393 482 x-=4;
10394 482 FireWeapon();
10395 482 x+=4;
10396 482 }
10397 8406 }
10398
10399 10777 clk3=0;
10400 10777 }
10401 }
10402 739432 }
10403
10404 1551984 return enemy::animate(index);
10405 1551984 }
10406
10407 1557825 void eProjectile::draw(BITMAP *dest)
10408 {
10409 1557825 update_enemy_frame();
10410 1557825 enemy::draw(dest);
10411 1557825 }
10412
10413 90 eTrigger::eTrigger(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10414 90 {
10415 90 hxofs=1000;
10416 90 }
10417
10418 12175 void eTrigger::draw(BITMAP *dest)
10419 {
10420 12175 update_enemy_frame();
10421 12175 enemy::draw(dest);
10422 12175 }
10423
10424 void eTrigger::death_sfx()
10425 {
10426 //silent death
10427 }
10428
10429 eNPC::eNPC(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10430 {
10431 o_tile+=wpnsbuf[iwNPCs].tile;
10432 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10433 SIZEflags = d->SIZEflags;
10434 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10435 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10436 // al_trace("Enemy txsz:%i\n", txsz);
10437 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10438 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10439 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10440 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10441 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10442 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10443 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10444 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10445 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10446 {
10447 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10448 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10449 }
10450
10451 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10452 }
10453
10454 bool eNPC::animate(int32_t index)
10455 {
10456 if(switch_hooked) return enemy::animate(index);
10457 if(dying)
10458 return Dead(index);
10459
10460 if(clk==0)
10461 {
10462 removearmos(x,y,ffcactivated);
10463 }
10464
10465 switch(dmisc2)
10466 {
10467 case 0:
10468 {
10469 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10470 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10471
10472 if((ddir<=(((-1)*PI)/4))&&(ddir>(((-3)*PI)/4)))
10473 {
10474 dir=down;
10475 }
10476
10477 else if((ddir<=(((1)*PI)/4))&&(ddir>(((-1)*PI)/4)))
10478 {
10479 dir=right;
10480 }
10481 else if((ddir<=(((3)*PI)/4))&&(ddir>(((1)*PI)/8)))
10482 {
10483 dir=up;
10484 }
10485 else
10486 {
10487 dir=left;
10488 }
10489 }
10490 break;
10491
10492 case 1:
10493 halting_walk(rate, homing, 0, hrate, 48);
10494
10495 if(clk2==1 && (misc < dmisc1) && !(zc_oldrand()&15))
10496 {
10497 newdir(rate, homing, 0);
10498 clk2=48;
10499 ++misc;
10500 }
10501
10502 if(clk2==0)
10503 misc=0;
10504
10505 break;
10506 }
10507
10508 return enemy::animate(index);
10509 }
10510
10511 void eNPC::draw(BITMAP *dest)
10512 {
10513 update_enemy_frame();
10514 enemy::draw(dest);
10515 }
10516
10517 int32_t eNPC::takehit(weapon*,weapon*)
10518 {
10519 return 0;
10520 }
10521
10522 94 eSpinTile::eSpinTile(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10523 94 {
10524
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if(clk>0) // clk>0 when created by a Spinning Tile combo
10525 {
10526 94 o_tile=clk;
10527 94 cs=id>>12;
10528 94 }
10529
10530 94 id=id&0xFFF;
10531 94 clk=0;
10532
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 step=0;
10533 94 mainguy=false;
10534 94 SIZEflags = d->SIZEflags;
10535
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10536 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10537 // al_trace("Enemy txsz:%i\n", txsz);
10538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10540
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10542
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10543
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10544 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10545
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10547 {
10548 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10549 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10550 }
10551
10552
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
94 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10553 94 }
10554
10555 81 void eSpinTile::facehero()
10556 {
10557
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 80 times.
81 if(Hero.x-x==0)
10558 {
10559
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (Hero.y + 8 < y)
10560 1 dir = up;
10561 else
10562 dir = down;
10563 1 }
10564 else
10565 {
10566 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10567 80 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10568
10569
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 58 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
80 if((ddir <= -5.0*PI/8.0) && (ddir > -7.0*PI/8.0))
10570 {
10571 12 dir=l_down;
10572 12 }
10573
4/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 1 times.
68 else if ((ddir <= -3.0*PI / 8.0) && (ddir > -5.0*PI / 8.0))
10574 {
10575 1 dir=down;
10576 1 }
10577
4/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 12 times.
67 else if ((ddir <= -1.0*PI / 8.0) && (ddir > -3.0*PI / 8.0))
10578 {
10579 12 dir=r_down;
10580 12 }
10581
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 39 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 6 times.
55 else if ((ddir <= 1.0*PI / 8.0) && (ddir > -1.0*PI / 8.0))
10582 {
10583 6 dir=right;
10584 6 }
10585
4/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 22 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 17 times.
49 else if ((ddir <= 3.0*PI / 8.0) && (ddir > 1.0*PI / 8.0))
10586 {
10587 17 dir=r_up;
10588 17 }
10589
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 8 times.
32 else if ((ddir <= 5.0*PI / 8.0) && (ddir > 3.0*PI / 8.0))
10590 {
10591 8 dir=up;
10592 8 }
10593
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
24 else if ((ddir <= 7.0*PI / 8.0) && (ddir > 5.0*PI / 8.0))
10594 {
10595 6 dir=l_up;
10596 6 }
10597 else
10598 {
10599 18 dir=left;
10600 }
10601 }
10602 81 }
10603
10604
10605 15539 bool eSpinTile::animate(int32_t index)
10606 {
10607
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15539 times.
15539 if(switch_hooked) return enemy::animate(index);
10608
2/4
✓ Branch 0 taken 15539 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15539 times.
15539 if(fallclk||drownclk) return enemy::animate(index);
10609
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 14387 times.
15539 if(dying)
10610 {
10611 1152 return Dead(index);
10612 }
10613
10614
2/2
✓ Branch 0 taken 13146 times.
✓ Branch 1 taken 1241 times.
14387 if(clk==0)
10615 {
10616 1241 removearmos(x,y,ffcactivated);
10617 1241 }
10618
10619 14387 ++misc;
10620
10621
2/2
✓ Branch 0 taken 14306 times.
✓ Branch 1 taken 81 times.
14387 if(misc==96)
10622 {
10623 81 facehero();
10624 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10625 81 double ddir=atan2_MSVC2022_FIX(double((Hero.y)-y),double(Hero.x-x));
10626 81 angular=true;
10627 81 angle=ddir;
10628 81 step=zslongToFix(dstep*100);
10629 81 }
10630
10631
8/8
✓ Branch 0 taken 14374 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 14359 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 14353 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 14335 times.
14387 if(y>186 || y<=-16 || x>272 || x<=-16)
10632 52 kickbucket();
10633
10634 14387 sprite::move(step);
10635 14387 return enemy::animate(index);
10636 15539 }
10637
10638 15457 void eSpinTile::draw(BITMAP *dest)
10639 {
10640 15457 update_enemy_frame();
10641 15457 y-=(misc>>4);
10642 15457 yofs+=2;
10643 15457 enemy::draw(dest);
10644 15457 yofs-=2;
10645 15457 y+=(misc>>4);
10646 15457 }
10647
10648 15457 void eSpinTile::drawshadow(BITMAP *dest, bool translucent)
10649 {
10650 15457 flip = 0;
10651 15457 shadowtile = wpnsbuf[spr_shadow].tile+(clk%4);
10652 15457 yofs+=4;
10653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15457 times.
15457 if(!shadow_overpit(this))
10654 15457 enemy::drawshadow(dest, translucent);
10655 15457 yofs-=4;
10656 15457 }
10657
10658 1605 eZora::eZora(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
10659 1605 {
10660 //these are here to bypass compiler warnings about unused arguments
10661 1605 Clk=Clk;
10662 1605 mainguy=false;
10663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10664 /*if((x>-17 && x<0) && iswaterex(tmpscr->data[(((int32_t)y&0xF0)+((int32_t)x>>4))]))
10665 {
10666 clk=1;
10667 }*/
10668 //nets+880;
10669 1605 SIZEflags = d->SIZEflags;
10670
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10671 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10672 // al_trace("Enemy txsz:%i\n", txsz);
10673
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10674
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10675
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10676
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10677
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10678
1/2
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10679 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10680
1/4
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10682 {
10683 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10684 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10685 }
10686
10687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1605 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1605 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10688 1605 }
10689
10690 392118 void eZora::facehero()
10691 {
10692
2/2
✓ Branch 0 taken 6564 times.
✓ Branch 1 taken 385554 times.
392118 if(Hero.x-x==0)
10693 {
10694 6564 dir=(Hero.y+8<y)?up:down;
10695 6564 }
10696 else
10697 {
10698 double _MSVC2022_tmp1, _MSVC2022_tmp2;
10699 385554 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
10700
10701
4/4
✓ Branch 0 taken 80572 times.
✓ Branch 1 taken 304982 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 49955 times.
385554 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
10702 {
10703 49955 dir=l_down;
10704 49955 }
10705
4/4
✓ Branch 0 taken 57428 times.
✓ Branch 1 taken 278171 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 26811 times.
335599 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
10706 {
10707 26811 dir=down;
10708 26811 }
10709
4/4
✓ Branch 0 taken 77619 times.
✓ Branch 1 taken 231169 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 47002 times.
308788 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
10710 {
10711 47002 dir=r_down;
10712 47002 }
10713
4/4
✓ Branch 0 taken 102786 times.
✓ Branch 1 taken 159000 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 72169 times.
261786 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
10714 {
10715 72169 dir=right;
10716 72169 }
10717
4/4
✓ Branch 0 taken 83714 times.
✓ Branch 1 taken 105903 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 53097 times.
189617 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
10718 {
10719 53097 dir=r_up;
10720 53097 }
10721
4/4
✓ Branch 0 taken 54641 times.
✓ Branch 1 taken 81879 times.
✓ Branch 2 taken 30617 times.
✓ Branch 3 taken 24024 times.
136520 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
10722 {
10723 24024 dir=up;
10724 24024 }
10725
4/4
✓ Branch 0 taken 76377 times.
✓ Branch 1 taken 36119 times.
✓ Branch 2 taken 45760 times.
✓ Branch 3 taken 30617 times.
112496 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
10726 {
10727 45760 dir=l_up;
10728 45760 }
10729 else
10730 {
10731 66736 dir=left;
10732 }
10733 }
10734 392118 }
10735
10736 554408 bool eZora::animate(int32_t index)
10737 {
10738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 554408 times.
554408 if(switch_hooked) return enemy::animate(index);
10739
2/2
✓ Branch 0 taken 1868 times.
✓ Branch 1 taken 552540 times.
554408 if(dying)
10740 1868 return Dead(index);
10741
10742
2/2
✓ Branch 0 taken 548931 times.
✓ Branch 1 taken 3609 times.
552540 if(clk==0)
10743 {
10744 3609 removearmos(x,y,ffcactivated);
10745 3609 }
10746
10747
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 552509 times.
552540 if(watch)
10748 {
10749 31 ++clock_zoras[id];
10750 31 return true;
10751 }
10752
10753
2/2
✓ Branch 0 taken 160391 times.
✓ Branch 1 taken 392118 times.
552509 if(get_qr(qr_NEWENEMYTILES))
10754 {
10755 392118 facehero();
10756 392118 }
10757
10758
6/6
✓ Branch 0 taken 3333 times.
✓ Branch 1 taken 3200 times.
✓ Branch 2 taken 2684 times.
✓ Branch 3 taken 537009 times.
✓ Branch 4 taken 4269 times.
✓ Branch 5 taken 2014 times.
552509 switch(clk)
10759 {
10760 case 0: // reposition him
10761 {
10762 4269 int32_t t=0;
10763 4269 int32_t pos2=zc_oldrand()%160 + 16;
10764 4269 bool placed=false;
10765
10766
4/4
✓ Branch 0 taken 4246 times.
✓ Branch 1 taken 20492 times.
✓ Branch 2 taken 12637 times.
✓ Branch 3 taken 3609 times.
24738 while(!placed && t<160)
10767 {
10768 12637 int32_t watertype = iswaterex(tmpscr->data[pos2], currmap, currscr, -1, ((pos2)%16*16), ((pos2)&0xF0), false, true, true, (bool)(editorflags & ENEMY_FLAG7));
10769
5/6
✓ Branch 0 taken 4326 times.
✓ Branch 1 taken 8311 times.
✓ Branch 2 taken 4326 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 330 times.
✓ Branch 5 taken 3586 times.
16553 if(watertype && ((editorflags & ENEMY_FLAG6) ||
10770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4326 times.
4326 ((combobuf[watertype].usrflags&cflag1) && (editorflags & ENEMY_FLAG5))
10771
3/4
✓ Branch 0 taken 4326 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3916 times.
✓ Branch 3 taken 3916 times.
4326 || (!(combobuf[watertype].usrflags&cflag1) && !(editorflags & ENEMY_FLAG5))) && (pos2&15)>0 && (pos2&15)<15)
10772 {
10773 3586 x=(pos2&15)<<4;
10774 3586 y=pos2&0xF0;
10775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3586 times.
3586 if (!(editorflags & ENEMY_FLAG8)) hp=guysbuf[id&0xFFF].hp; // refill life each time, unless the flag is checked.
10776 3586 hxofs=1000; // avoid hit detection
10777 3586 stunclk=0;
10778 3586 placed=true;
10779 3586 }
10780
10781 20469 pos2+=19;
10782
10783
2/2
✓ Branch 0 taken 18055 times.
✓ Branch 1 taken 2414 times.
20469 if(pos2>=176)
10784 2414 pos2-=160;
10785
10786 20469 ++t;
10787 }
10788
10789
3/4
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3586 times.
3609 if(!placed || whistleclk>=88) // can't place him, he's gone
10790 23 return true;
10791
10792 }
10793 3586 break;
10794
10795 case 35:
10796
2/2
✓ Branch 0 taken 2368 times.
✓ Branch 1 taken 965 times.
3333 if(!get_qr(qr_NEWENEMYTILES))
10797 {
10798 965 dir=(Hero.y+8<y)?up:down;
10799 965 }
10800
10801 3333 hxofs=0;
10802 3333 break;
10803
10804 case 35+19:
10805 3200 addEwpn(x,y,z,wpn,2,wdp,dir,getUID(), 0, fakez);
10806 3200 sfx(wpnsfx(wpn),pan(int32_t(x)));
10807 3200 break;
10808
10809 case 35+66:
10810 2684 hxofs=1000;
10811 2684 break;
10812
10813 case 198:
10814 2014 clk=-1;
10815 2014 break;
10816 }
10817
10818 551826 return enemy::animate(index);
10819 553748 }
10820
10821 554283 void eZora::draw(BITMAP *dest)
10822 {
10823
2/2
✓ Branch 0 taken 10764 times.
✓ Branch 1 taken 543519 times.
554283 if(clk<3)
10824 10764 return;
10825
10826 543519 update_enemy_frame();
10827 543519 enemy::draw(dest);
10828 554283 }
10829
10830 bool eZora::isSubmerged() const
10831 {
10832 return ( clk < 3 );
10833 }
10834
10835
3/6
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26760 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26760 times.
✗ Branch 5 not taken.
53520 eStalfos::eStalfos(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
10836 26760 {
10837 26760 multishot= timer = fired = dashing = 0;
10838 26760 hashero = false;
10839 26760 dummy_bool[0]=false;
10840 26760 shield= (flags&(inv_left | inv_right | inv_back |inv_front)) != 0;
10841
5/6
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✓ Branch 5 taken 71 times.
26760 if(dmisc9==e9tARMOS && zc_oldrand()&1)
10842 {
10843
2/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
76 step=zslongToFix(dmisc10*100);
10844
10845
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 64 times.
76 if(anim==aARMOS4) o_tile+=20;
10846 76 }
10847
10848
2/2
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 26613 times.
26760 if(flags & guy_fadeflicker)
10849 {
10850 147 clk=0;
10851 147 superman = 1;
10852 147 fading=fade_flicker;
10853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
147 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
10854 147 dir=down;
10855
10856
4/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✓ Branch 5 taken 80 times.
147 if(!canmove(down,(zfix)8,spw_none,false))
10857
3/6
✓ Branch 0 taken 67 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 67 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 67 times.
✗ Branch 5 not taken.
67 clk3=int32_t(13.0/step);
10858 147 }
10859
2/2
✓ Branch 0 taken 26612 times.
✓ Branch 1 taken 1 times.
26613 else if(flags & guy_fadeinstant)
10860 {
10861 1 clk=0;
10862 1 }
10863
10864
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 shadowdistance = 0;
10865 26760 clk4 = clk5 = 0;
10866 //nets+2380;
10867 26760 SIZEflags = d->SIZEflags;
10868
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
10869 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
10870 // al_trace("Enemy txsz:%i\n", txsz);
10871
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
10872
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
10873
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
10874
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
10875
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
10876
1/2
✓ Branch 0 taken 26760 times.
✗ Branch 1 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
10877 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
10878
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
10879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
10880 {
10881 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
10882 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
10883 }
10884
10885
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26760 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
26760 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
10886 26760 }
10887
10888 9630028 bool eStalfos::animate(int32_t index)
10889 {
10890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9630028 times.
9630028 if(switch_hooked) return enemy::animate(index);
10891
3/4
✓ Branch 0 taken 9629886 times.
✓ Branch 1 taken 142 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9629886 times.
9630028 if(fallclk||drownclk)
10892 {
10893 142 return enemy::animate(index);
10894 }
10895
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 9421987 times.
9629886 if(dying)
10896 {
10897
2/2
✓ Branch 0 taken 207868 times.
✓ Branch 1 taken 31 times.
207899 if(hashero)
10898 {
10899 31 Hero.setEaten(0);
10900 31 hashero=false;
10901 31 }
10902
10903
10/14
✓ Branch 0 taken 20374 times.
✓ Branch 1 taken 187525 times.
✓ Branch 2 taken 1140 times.
✓ Branch 3 taken 19234 times.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 1091 times.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✓ Branch 13 taken 49 times.
207899 if(dmisc9==e9tROPE && dmisc2==e2tBOMBCHU && !fired && (hp<=0 && !immortal) && hp>-1000 && wpn>wEnemyWeapons)
10904 {
10905 49 hp=-1000;
10906
5/10
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
49 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID(),false);
10907 49 Ewpns.add(ew);
10908 49 ew->fakez = fakez;
10909
10910
2/4
✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
49 if(wpn==ewSBomb || wpn==ewBomb)
10911 {
10912 49 ew->step=0;
10913 49 ew->id=wpn;
10914 49 ew->misc=50;
10915 49 ew->clk=48;
10916 49 }
10917
10918 49 fired=true;
10919 49 }
10920
6/6
✓ Branch 0 taken 95092 times.
✓ Branch 1 taken 112758 times.
✓ Branch 2 taken 77556 times.
✓ Branch 3 taken 17536 times.
✓ Branch 4 taken 77538 times.
✓ Branch 5 taken 18 times.
207850 else if(wpn && wpn!=ewBrang && dmisc2==e2tFIREOCTO) // Fire Octo
10921 {
10922
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 1 times.
18 if(!dummy_bool[0])
10923 {
10924 1 int32_t wpn2 = wpn+dmisc3;
10925
10926
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn2 <= wEnemyWeapons || wpn2 >= wMax)
10927 {
10928 wpn2=wpn;
10929 }
10930
10931 1 dummy_bool[0]=true;
10932 1 addEwpn(x,y,z,wpn2,0,dmisc4,up, getUID(), 0, fakez);
10933 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10934 1 addEwpn(x,y,z,wpn2,0,dmisc4,down, getUID(), 0, fakez);
10935 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10936 1 addEwpn(x,y,z,wpn2,0,dmisc4,left, getUID(), 0, fakez);
10937 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10938 1 addEwpn(x,y,z,wpn2,0,dmisc4,right, getUID(), 0, fakez);
10939 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10940 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_up, getUID(), 0, fakez);
10941 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10942 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_up, getUID(), 0, fakez);
10943 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10944 1 addEwpn(x,y,z,wpn2,0,dmisc4,l_down, getUID(), 0, fakez);
10945 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10946 1 addEwpn(x,y,z,wpn2,0,dmisc4,r_down, getUID(), 0, fakez);
10947 1 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
10948 1 sfx(wpnsfx(wpn2),pan(int32_t(x)));
10949 1 }
10950 18 }
10951
10952 207899 KillWeapon();
10953 207899 return Dead(index);
10954 }
10955 //vire split
10956 //2.10 checked !fslide(), but nothing uses that now anyway. -Z
10957 //Perhaps the problem occurs when vires die because they have < 0 HP, in this check?
10958
13/14
✓ Branch 0 taken 11844 times.
✓ Branch 1 taken 9410143 times.
✓ Branch 2 taken 11844 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 149 times.
✓ Branch 5 taken 11695 times.
✓ Branch 6 taken 819531 times.
✓ Branch 7 taken 8602307 times.
✓ Branch 8 taken 818273 times.
✓ Branch 9 taken 1258 times.
✓ Branch 10 taken 4401 times.
✓ Branch 11 taken 813872 times.
✓ Branch 12 taken 803 times.
✓ Branch 13 taken 3598 times.
9421987 else if(((hp<=0 && !immortal) && dmisc2==e2tSPLIT) || (dmisc2==e2tSPLITHIT && hp>0 && hp<guysbuf[id&0xFFF].hp && !slide() && (sclk&255)<=1)) //Split into enemies
10959 {
10960 952 stop_bgsfx(index);
10961 952 int32_t kids = guys.Count();
10962 952 int32_t id2=dmisc3;
10963
2/2
✓ Branch 0 taken 1890 times.
✓ Branch 1 taken 952 times.
2842 for(int32_t i=0; i < dmisc4; i++)
10964 {
10965 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10966
4/6
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 1334 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1334 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1890 times.
1890 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((editorflags & ENEMY_FLAG5) ? 0 : (i<<12))),-21-(i%4)))
10967 1890 ((enemy*)guys.spr(kids+i))->count_enemy = false;
10968 1890 }
10969
10970
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(itemguy) // Hand down the carried item
10971 {
10972 guycarryingitem = guys.Count()-1;
10973 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
10974 itemguy = false;
10975 }
10976
10977
1/2
✓ Branch 0 taken 952 times.
✗ Branch 1 not taken.
952 if(hashero)
10978 {
10979 Hero.setEaten(0);
10980 hashero=false;
10981 }
10982
10983
4/4
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 803 times.
✓ Branch 3 taken 135 times.
952 if(deadsfx > 0 && dmisc2==e2tSPLIT)
10984 135 sfx(deadsfx,pan(int32_t(x)));
10985
10986 952 return true;
10987 }
10988 /*
10989 else if((dmisc2==e2tSPLITHIT && (hp<=0 && !immortal) &&!slide())) //Possible vires fix; or could cause goodness knows what. -Z
10990 {
10991 stop_bgsfx(index);
10992 int32_t kids = guys.Count();
10993 int32_t id2=dmisc3;
10994
10995 for(int32_t i=0; i < dmisc4; i++)
10996 {
10997 // if (addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : ((i+1)<<12)),-21-(i%4)))
10998 if(addenemy(x,y,id2+(guysbuf[id2].family==eeKEESE ? 0 : (i<<12)),-21-(i%4)))
10999 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11000 }
11001
11002 if(itemguy) // Hand down the carried item
11003 {
11004 guycarryingitem = guys.Count()-1;
11005 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11006 itemguy = false;
11007 }
11008
11009 if(hashero)
11010 {
11011 Hero.setEaten(0);
11012 hashero=false;
11013 }
11014
11015 return true;
11016 }
11017 */
11018
2/2
✓ Branch 0 taken 12521 times.
✓ Branch 1 taken 9408514 times.
9421035 if(fading)
11019 {
11020
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 12312 times.
12521 if(++clk4 > 60)
11021 {
11022 209 clk4=0;
11023 209 superman=0;
11024 209 fading=0;
11025
11026
4/6
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 146 times.
209 if(flags2&cmbflag_armos && z==0 && fakez == 0)
11027 {
11028 //if a custom size (not 16px by 16px)
11029
11030 //if a custom size (not 16px by 16px)
11031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 146 times.
146 if (ffcactivated)
11032 removearmosffc(ffcactivated-1);
11033 else
11034 {
11035
4/8
✓ Branch 0 taken 146 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 146 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 146 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 146 times.
146 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11036 {
11037 //zprint("spawn big enemy from armos\n");
11038 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11039 for(int32_t dx = 0; dx < tysz; dx ++)
11040 {
11041 for(int32_t dy = 0; dy < tysz; dy++)
11042 {
11043 removearmos((int32_t)x+(dx*16),(int32_t)y+(dy*16)+1);
11044 did_armos = false;
11045 }
11046 removearmos((int32_t)x+(dx*16), (int32_t)y+((tysz-1)*16)+1);
11047 did_armos = false;
11048 }
11049 for(int32_t dy = 0; dy < tysz; dy ++)
11050 {
11051 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+(dy*16)+1);
11052 did_armos = false;
11053 }
11054 removearmos((int32_t)x+((txsz-1)*16), (int32_t)y+((tysz-1)*16)+1);
11055 }
11056 146 else removearmos(x,y);
11057 }
11058 /*
11059 if (txsz > 1 || tysz > 1 || (SIZEflags&guyflagOVERRIDE_HIT_WIDTH) || (SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) )//remove more than one combo based on enemy size
11060 {
11061 //if removing a block, then adjust y by -1 as the enemy spawns at y+1
11062 for(int32_t dx = 0; dx < hxsz; dx += 16)
11063 {
11064 for(int32_t dy = 0; dy < hysz; dy += 16)
11065 {
11066 removearmos((int32_t)x+dx+hxofs,(int32_t)y+dy+hyofs+1,ffcactivated);
11067 did_armos = false;
11068 }
11069 removearmos((int32_t)x+dx+hxofs, (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11070 did_armos = false;
11071 }
11072 for(int32_t dy = 0; dy < hysz; dy += 16)
11073 {
11074 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+dy+hyofs-1,ffcactivated);
11075 did_armos = false;
11076 }
11077 removearmos((int32_t)x+hxofs+(hxsz-1), (int32_t)y+hyofs+(hysz-1)-1,ffcactivated);
11078 }
11079 else removearmos(x,y,ffcactivated);
11080 */
11081
11082 146 }
11083
11084 209 clk2=0;
11085
11086 209 newdir();
11087 209 }
11088 12312 else return enemy::animate(index);
11089 209 }
11090
6/8
✓ Branch 0 taken 33168 times.
✓ Branch 1 taken 9375346 times.
✓ Branch 2 taken 33168 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33168 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31059 times.
✓ Branch 7 taken 2109 times.
9408514 else if(flags2&cmbflag_armos && z==0 && fakez == 0 && clk==0)
11091 2109 removearmos(x,y,ffcactivated);
11092
11093
11094
2/2
✓ Branch 0 taken 2540 times.
✓ Branch 1 taken 9406183 times.
9408723 if(hashero)
11095 {
11096 2540 Hero.setX(x);
11097 2540 Hero.setY(y);
11098 2540 ++clk2;
11099
11100
4/4
✓ Branch 0 taken 1027 times.
✓ Branch 1 taken 1513 times.
✓ Branch 2 taken 2489 times.
✓ Branch 3 taken 51 times.
2540 if(clk2==(dmisc8==0 ? 95 : dmisc8))
11101 {
11102
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
51 switch(dmisc7)
11103 {
11104 case e7tEATITEMS:
11105 {
11106
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<MAXITEMS; i++)
11107 {
11108
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 1 times.
256 if(itemsbuf[i].flags&ITEM_EDIBLE)
11109 1 game->set_item(i, false);
11110 256 }
11111
11112 1 break;
11113 }
11114
11115 case e7tEATMAGIC:
11116 game->change_dmagic(-1*game->get_magicdrainrate());
11117 break;
11118
11119 case e7tEATRUPEES:
11120 game->change_drupy(-1);
11121 break;
11122 }
11123
11124 51 clk2=0;
11125 51 }
11126
11127
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 2335 times.
2540 if((clk&0x18)==8) // stop its animation on the middle frame
11128 2335 --clk;
11129 2540 }
11130
4/4
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8706069 times.
✓ Branch 2 taken 408221 times.
✓ Branch 3 taken 291893 times.
9406183 else if(!(wpn==ewBrang && WeaponOut())) //WeaponOut uses misc
11131 {
11132 // Movement engine
11133
4/6
✓ Branch 0 taken 504520 times.
✓ Branch 1 taken 8609770 times.
✓ Branch 2 taken 2332 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8607438 times.
✗ Branch 5 not taken.
9114290 if(clk>=0) switch(id>>12)
11134 {
11135 case 0: // Normal movement
11136
11137 /*
11138 if((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && !slide()) //Leever
11139 {
11140 // Overloading clk4 (Tribble clock) here...
11141 step=17/100.0;
11142 if(clk4<32) misc=1;
11143 else if(clk4<48) misc=2;
11144 else if(clk4<300) { misc=3; step = dstep/100.0; }
11145 else if(clk4<316) misc=2;
11146 else if(clk4<412) misc=1;
11147 else if(clk4<540) { misc=0; step=0; }
11148 else clk4=0;
11149 if(clk4==48) clk=0;
11150 hxofs=(misc>=2)?0:1000;
11151 if (dmisc9==e9tLEEVER)
11152 variable_walk(rate, homing, 0);
11153 else
11154 variable_walk_8(rate, homing, 4, 0);
11155 break;
11156 }
11157 */
11158
4/4
✓ Branch 0 taken 8408380 times.
✓ Branch 1 taken 199058 times.
✓ Branch 2 taken 273002 times.
✓ Branch 3 taken 8135378 times.
8607438 if(dmisc9==e9tVIRE || dmisc9==e9tPOLSVOICE) //Vire
11159 {
11160 472060 vire_hop();
11161 472060 break;
11162 }
11163
2/2
✓ Branch 0 taken 649572 times.
✓ Branch 1 taken 7485806 times.
8135378 else if(dmisc9==e9tROPE) //Rope charge
11164 {
11165
9/10
✓ Branch 0 taken 632150 times.
✓ Branch 1 taken 17422 times.
✓ Branch 2 taken 89355 times.
✓ Branch 3 taken 542795 times.
✓ Branch 4 taken 80424 times.
✓ Branch 5 taken 8931 times.
✓ Branch 6 taken 79638 times.
✓ Branch 7 taken 786 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79638 times.
649572 if(!fired && dashing && !stunclk && !watch && !frozenclock)
11166 {
11167
5/6
✓ Branch 0 taken 2372 times.
✓ Branch 1 taken 77266 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 2357 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 15 times.
79638 if(dmisc2==e2tBOMBCHU && HeroInRange(16) && wpn+dmisc3 > wEnemyWeapons) //Bombchu
11168 {
11169
11170
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1 times.
15 if ( get_qr(qr_BOMBCHUSUPERBOMB) )
11171 {
11172 14 hp=-1000;
11173
11174
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11175 {
11176
5/10
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
14 weapon *ew=new weapon(x,y,z, wpn+dmisc3, 0, dmisc4, dir,-1,getUID());
11177 14 Ewpns.add(ew);
11178 14 ew->fakez = fakez;
11179
11180
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
14 if(wpn==ewSBomb || wpn==ewBomb)
11181 {
11182 14 ew->step=0;
11183 14 ew->id=wpn+dmisc3;
11184 14 ew->misc=50;
11185 14 ew->clk=48;
11186 14 }
11187
11188 14 fired=true;
11189 14 }
11190 else
11191 {
11192 weapon *ew=new weapon(x,y,z, wpn, 0, dmisc4, dir,-1,getUID());
11193 Ewpns.add(ew);
11194 ew->fakez = fakez;
11195
11196 if(wpn==ewSBomb || wpn==ewBomb)
11197 {
11198 ew->step=0;
11199 ew->id=wpn;
11200 ew->misc=50;
11201 ew->clk=48;
11202 }
11203
11204 fired=true;
11205 }
11206 14 }
11207
11208 else
11209 {
11210 1 hp=-1000;
11211
11212 int32_t wpn2;
11213
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(wpn+dmisc3 > wEnemyWeapons && wpn+dmisc3 < wMax)
11214 1 wpn2=wpn;
11215 else
11216 wpn2=wpn;
11217
11218
5/10
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
1 weapon *ew=new weapon(x,y,z, wpn2, 0, dmisc4, dir,-1,getUID());
11219 1 Ewpns.add(ew);
11220 1 ew->fakez = fakez;
11221
11222
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(wpn2==ewSBomb || wpn2==ewBomb)
11223 {
11224 1 ew->step=0;
11225 1 ew->id=wpn2;
11226 1 ew->misc=50;
11227 1 ew->clk=48;
11228 1 }
11229
11230 1 fired=true;
11231 }
11232 15 }
11233 79638 }
11234
11235 649572 charge_attack();
11236 649572 break;
11237 }
11238 /*
11239 * Boomerang-throwers have a halt count of 1
11240 * Zols have a halt count of (zc_oldrand()&7)<<4
11241 * Gels have a halt count of ((zc_oldrand()&7)<<3)+2
11242 * Everything else has 48
11243 */
11244 else
11245 {
11246
2/2
✓ Branch 0 taken 378407 times.
✓ Branch 1 taken 7107399 times.
7485806 if(wpn==ewBrang) // Goriya
11247 {
11248 378407 halting_walk(rate,homing,0,hrate, 1);
11249 378407 }
11250
4/4
✓ Branch 0 taken 7074085 times.
✓ Branch 1 taken 33314 times.
✓ Branch 2 taken 2912329 times.
✓ Branch 3 taken 4161756 times.
7107399 else if(dmisc9==e9tNORMAL && wpn==0)
11251 {
11252
2/2
✓ Branch 0 taken 574887 times.
✓ Branch 1 taken 3586869 times.
4161756 if(dmisc2==e2tSPLITHIT) // Zol
11253 {
11254 574887 halting_walk(rate,homing,0,hrate,(zc_oldrand()&7)<<4);
11255 574887 }
11256
4/4
✓ Branch 0 taken 1147347 times.
✓ Branch 1 taken 2439522 times.
✓ Branch 2 taken 1047903 times.
✓ Branch 3 taken 99444 times.
3586869 else if(frate<=8 && starting_hp==1) // Gel
11257 {
11258 99444 halting_walk(rate,homing,0,hrate,((zc_oldrand()&7)<<3)+2);
11259 99444 }
11260 else // Other
11261 {
11262 3487425 halting_walk(rate,homing,0,hrate, 48);
11263 }
11264 4161756 }
11265 else // Other
11266 {
11267 2945643 halting_walk(rate,homing,0,hrate, 48);
11268 }
11269 }
11270
11271 //if not in midair, and Hero's swinging sword is nearby, jump.
11272 /*if (dmisc9==e9tZ3STALFOS && z==0 && (!(isSideViewGravity()) || !_walkflag(x,y+16,0))
11273 && Hero.getAttackClk()==5 && Hero.getAttack()==wSword && distance(x,y,Hero.getX(),Hero.getY())<32)
11274 {
11275 facehero(false);
11276 sclk=16+((dir^1)<<8);
11277 fall=-FEATHERJUMP;
11278 sfx(WAV_ZN1JUMP,pan(int32_t(x)));
11279 }*/
11280 7485806 break;
11281
11282 // Following cases are for just after creation-by-splitting.
11283 case 1:
11284
2/2
✓ Branch 0 taken 1752 times.
✓ Branch 1 taken 580 times.
2332 if(misc==1)
11285 {
11286 580 dir=up;
11287 580 step=8;
11288 580 }
11289
11290
2/2
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 1773 times.
2332 if(misc<=2)
11291 {
11292 1773 move(step);
11293
11294
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 343 times.
1773 if(!canmove(dir,(zfix)0,0,false))
11295 343 dir=down;
11296 1773 }
11297
11298
2/2
✓ Branch 0 taken 1773 times.
✓ Branch 1 taken 559 times.
2332 if(misc==3)
11299 {
11300
2/2
✓ Branch 0 taken 209 times.
✓ Branch 1 taken 350 times.
559 if(canmove(right,(zfix)16,0,false))
11301 350 x+=16;
11302 559 }
11303
11304 2332 ++misc;
11305 2332 break;
11306
11307 case 2:
11308 if(misc==1)
11309 {
11310 dir=down;
11311 step=8;
11312 }
11313
11314 if(misc<=2)
11315 {
11316 move(step);
11317 /*
11318 if(!canmove(dir,(zfix)0,0,false))
11319 dir=up;
11320 */
11321 }
11322
11323 if(misc==3)
11324 {
11325 if(canmove(left,(zfix)16,0,false))
11326 x-=16;
11327 }
11328
11329 ++misc;
11330 break;
11331
11332 default:
11333 if(misc==1)
11334 {
11335 dir=(zc_oldrand()%4);
11336 step=8;
11337 }
11338
11339 if(misc<=2)
11340 {
11341 move(step);
11342
11343 if(!canmove(dir,(zfix)0,0,false))
11344 dir=dir^1;
11345 }
11346
11347 if(misc==3)
11348 {
11349 if(dir >= left && canmove(dir,(zfix)16,0,false))
11350 x+=(dir==left ? -16 : 16);
11351 }
11352
11353 ++misc;
11354 break;
11355 8609770 }
11356
11357
4/4
✓ Branch 0 taken 16816 times.
✓ Branch 1 taken 9097474 times.
✓ Branch 2 taken 16257 times.
✓ Branch 3 taken 559 times.
9114290 if(id>>12 && misc>=4) //recently spawned by a split enemy
11358 {
11359 559 id&=0xFFF;
11360 559 step = zslongToFix(dstep*100);
11361
11362
1/2
✓ Branch 0 taken 559 times.
✗ Branch 1 not taken.
559 if(x<32) x=32;
11363
11364
2/2
✓ Branch 0 taken 546 times.
✓ Branch 1 taken 13 times.
559 if(x>208) x=208;
11365
11366
2/2
✓ Branch 0 taken 541 times.
✓ Branch 1 taken 18 times.
559 if(y<32) y=32;
11367
11368
2/2
✓ Branch 0 taken 554 times.
✓ Branch 1 taken 5 times.
559 if(y>128) y=128;
11369
11370 559 misc=3;
11371 559 }
11372 9114290 }
11373 else
11374 {
11375 //sfx(wpnsfx(wpn),pan(int32_t(x)));
11376
1/2
✓ Branch 0 taken 291893 times.
✗ Branch 1 not taken.
291893 if(clk2>2) clk2--;
11377 }
11378
11379 // Fire Zol
11380
7/8
✓ Branch 0 taken 3944791 times.
✓ Branch 1 taken 5463932 times.
✓ Branch 2 taken 6634 times.
✓ Branch 3 taken 3938157 times.
✓ Branch 4 taken 47 times.
✓ Branch 5 taken 6587 times.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
9408723 if(wpn && dmisc1==e1tEACHTILE && clk2==1 && !hclk)
11381 {
11382 47 addEwpn(x,y,z,wpn,0,wdp,dir, getUID(), 0, fakez);
11383 47 sfx(wpnsfx(wpn),pan(int32_t(x)));
11384
11385 47 int32_t i=Ewpns.Count()-1;
11386 47 weapon *ew = (weapon*)(Ewpns.spr(i));
11387
11388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
47 if(wpn==ewFIRETRAIL && wpnsbuf[ewFIRETRAIL].frames>1)
11389 {
11390 ew->aframe=zc_oldrand()%wpnsbuf[ewFIRETRAIL].frames;
11391 if ( ew->do_animation ) ew->tile+=ew->aframe;
11392 }
11393 47 }
11394 // Goriya
11395
14/16
✓ Branch 0 taken 700114 times.
✓ Branch 1 taken 8708562 times.
✓ Branch 2 taken 318261 times.
✓ Branch 3 taken 381853 times.
✓ Branch 4 taken 310952 times.
✓ Branch 5 taken 7309 times.
✓ Branch 6 taken 286403 times.
✓ Branch 7 taken 24549 times.
✓ Branch 8 taken 286403 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 283662 times.
✓ Branch 11 taken 2741 times.
✓ Branch 12 taken 283662 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 279458 times.
✓ Branch 15 taken 4204 times.
9408676 else if(wpn==ewBrang && clk2==1 && sclk==0 && !stunclk && !frozenclock && !watch && wpn && !WeaponOut())
11396 {
11397 4204 misc=index+100;
11398
7/14
✓ Branch 0 taken 4204 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4204 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4204 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4204 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4204 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4204 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4204 times.
✗ Branch 13 not taken.
4204 Ewpns.add(new weapon(x,y-fakez,z,wpn,misc,wdp,dir, -1,getUID(),false));
11399 4204 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=false;
11400
11401
2/2
✓ Branch 0 taken 4049 times.
✓ Branch 1 taken 155 times.
4204 if(dmisc1==2)
11402 {
11403 155 int32_t ndir=dir;
11404
11405
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 151 times.
155 if(Hero.x-x==0)
11406 {
11407 4 ndir=(Hero.y+8<y)?up:down;
11408 4 }
11409 else //turn to face Hero
11410 {
11411 double _MSVC2022_tmp1, _MSVC2022_tmp2;
11412 151 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
11413
11414
4/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 9 times.
151 if((ddir<=(((-2)*PI)/8))&&(ddir>(((-6)*PI)/8)))
11415 {
11416 9 ndir=down;
11417 9 }
11418
4/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 41 times.
142 else if((ddir<=(((2)*PI)/8))&&(ddir>(((-2)*PI)/8)))
11419 {
11420 41 ndir=right;
11421 41 }
11422
4/4
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 51 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 33 times.
101 else if((ddir<=(((6)*PI)/8))&&(ddir>(((2)*PI)/8)))
11423 {
11424 33 ndir=up;
11425 33 }
11426 else
11427 {
11428 68 ndir=left;
11429 }
11430 }
11431
11432 155 ((weapon*)Ewpns.spr(Ewpns.Count()-1))->dummy_bool[0]=true;
11433
11434
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 153 times.
155 if(canmove(ndir,false))
11435 {
11436 153 dir=ndir;
11437 153 }
11438 155 }
11439 4204 }
11440
15/16
✓ Branch 0 taken 9367609 times.
✓ Branch 1 taken 36863 times.
✓ Branch 2 taken 121574 times.
✓ Branch 3 taken 9282898 times.
✓ Branch 4 taken 106507 times.
✓ Branch 5 taken 15067 times.
✓ Branch 6 taken 91800 times.
✓ Branch 7 taken 14707 times.
✓ Branch 8 taken 91114 times.
✓ Branch 9 taken 686 times.
✓ Branch 10 taken 82969 times.
✓ Branch 11 taken 8145 times.
✓ Branch 12 taken 82969 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 944 times.
✓ Branch 15 taken 82025 times.
9404472 else if((clk2==16 || dmisc1==e1tCONSTANT) && dmisc1!=e1tEACHTILE && wpn && wpn!=ewBrang && sclk==0 && !stunclk && !frozenclock && !watch)
11441
3/3
✓ Branch 0 taken 16959 times.
✓ Branch 1 taken 64165 times.
✓ Branch 2 taken 901 times.
82025 switch(dmisc1)
11442 {
11443 case e1tCONSTANT: //Deathnut
11444 {
11445 // Overloading clk5 (Like Like clock) to avoid making another clock just for this attack...
11446
2/2
✓ Branch 0 taken 62822 times.
✓ Branch 1 taken 1343 times.
64165 if(clk5>64)
11447 {
11448 1343 clk5=0;
11449 1343 fired=false;
11450 1343 }
11451
11452 64165 clk5+=(zc_oldrand()&3);
11453
11454
4/4
✓ Branch 0 taken 39489 times.
✓ Branch 1 taken 24676 times.
✓ Branch 2 taken 13354 times.
✓ Branch 3 taken 26135 times.
64165 if((clk5>24)&&(clk5<52))
11455 {
11456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26135 times.
26135 if ( do_animation )tile+=20; //firing
11457
11458
4/4
✓ Branch 0 taken 14252 times.
✓ Branch 1 taken 11883 times.
✓ Branch 2 taken 12803 times.
✓ Branch 3 taken 1449 times.
26135 if(!fired&&(clk5>=38))
11459 {
11460
5/10
✓ Branch 0 taken 1449 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1449 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1449 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1449 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1449 times.
✗ Branch 9 not taken.
1449 Ewpns.add(new weapon(x,y,z, wpn, 0, wdp, dir, -1,getUID(),false));
11461 1449 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
11462 1449 sfx(wpnsfx(wpn),pan(int32_t(x)));
11463 1449 fired=true;
11464 1449 }
11465 26135 }
11466
11467 64165 break;
11468 }
11469
11470 case e1tFIREOCTO: //Fire Octo
11471 901 timer=zc_oldrand()%50+50;
11472 901 break;
11473
11474 default:
11475 16959 FireWeapon();
11476 16959 break;
11477 82025 }
11478
11479 /* Fire again if:
11480 * - clk2 about to run out
11481 * - not already double-firing (dmisc1 is 1)
11482 * - not carrying Hero
11483 * - one in 0xF chance
11484 */
11485
8/10
✓ Branch 0 taken 352788 times.
✓ Branch 1 taken 9055935 times.
✓ Branch 2 taken 3024 times.
✓ Branch 3 taken 349764 times.
✓ Branch 4 taken 3024 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3024 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2830 times.
✓ Branch 9 taken 194 times.
9408723 if(clk2==1 && (multishot < dmisc6) && dmisc1 != e1tEACHTILE && !hashero && !(zc_oldrand()&15))
11486 {
11487 #if 1
11488 194 newdir(rate, homing, grumble);
11489 #else
11490 dir^=2;
11491 #endif
11492 194 clk2=28;
11493 194 ++multishot;
11494 194 }
11495
11496
2/2
✓ Branch 0 taken 2280564 times.
✓ Branch 1 taken 7128159 times.
9408723 if(clk2==0)
11497 {
11498 7128159 multishot = 0;
11499 7128159 }
11500
11501
2/2
✓ Branch 0 taken 9344606 times.
✓ Branch 1 taken 64117 times.
9408723 if(timer) //Fire Octo
11502 {
11503 64117 clk2=15; //this keeps the octo in place until he's done firing
11504
11505
2/2
✓ Branch 0 taken 48413 times.
✓ Branch 1 taken 15704 times.
64117 if(!(timer%4))
11506 {
11507 15704 FireBreath(false);
11508 15704 }
11509
11510 64117 --timer;
11511 64117 }
11512
11513
2/2
✓ Branch 0 taken 9231894 times.
✓ Branch 1 taken 176829 times.
9408723 if(dmisc2==e2tTRIBBLE)
11514 176829 ++clk4;
11515
11516
7/10
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 9406483 times.
✓ Branch 2 taken 607 times.
✓ Branch 3 taken 9408116 times.
✓ Branch 4 taken 607 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 607 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 607 times.
9408723 if(clk4==(dmisc5 ? dmisc5 : 256) && (dmisc2==e2tTRIBBLE) && dmisc3 && dmisc4)
11517 {
11518 607 int32_t kids = guys.Count();
11519 607 int32_t id2=dmisc3;
11520
11521
2/2
✓ Branch 0 taken 607 times.
✓ Branch 1 taken 607 times.
1214 for(int32_t i=0; i<dmisc4; i++)
11522 {
11523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
607 if(addenemy(x,y,id2,-24))
11524 {
11525
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(itemguy) // Hand down the carried item
11526 {
11527 guycarryingitem = guys.Count()-1;
11528 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11529 itemguy = false;
11530 }
11531
11532 607 ((enemy*)guys.spr(kids+i))->count_enemy = false;
11533 607 }
11534 607 }
11535
11536
1/2
✓ Branch 0 taken 607 times.
✗ Branch 1 not taken.
607 if(hashero)
11537 {
11538 Hero.setEaten(0);
11539 hashero=false;
11540 }
11541
11542 607 stop_bgsfx(index);
11543 607 return true;
11544 }
11545
11546 9408116 return enemy::animate(index);
11547 9630028 }
11548
11549 9950483 void eStalfos::draw(BITMAP *dest)
11550 {
11551 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc<=0) //Submerged
11552 {
11553 clk4--; //Kludge
11554 return;
11555 }*/
11556
11557 /*if ((dmisc9==e9tLEEVER || dmisc9==e9tZ3LEEVER) && misc>1)
11558 {
11559 cs = dcset;
11560 }*/
11561 9950483 update_enemy_frame();
11562
11563
7/8
✓ Branch 0 taken 9950341 times.
✓ Branch 1 taken 142 times.
✓ Branch 2 taken 9950341 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35975 times.
✓ Branch 5 taken 9914366 times.
✓ Branch 6 taken 33085 times.
✓ Branch 7 taken 2890 times.
9950483 if(!fallclk&&!drownclk&&(dmisc2==e2tBOMBCHU)&&dashing)
11564 {
11565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2890 times.
2890 if ( do_animation )tile+=20;
11566 2890 }
11567
11568 9950483 enemy::draw(dest);
11569 9950483 }
11570
11571 2685346 void eStalfos::drawshadow(BITMAP *dest, bool translucent)
11572 {
11573 2685346 int32_t tempy=yofs;
11574
11575 /*
11576 if (clk6 && dir>=left && !get_qr(qr_ENEMIESZAXIS)) {
11577 flip = 0;
11578 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11579 (clk/(frate/4)):((clk>=(frate>>1))?1:0);
11580 shadowtile = wpnsbuf[spr_shadow].tile+f2;
11581 yofs+=(((int32_t)y+17)&0xF0)-y;
11582 yofs+=8;
11583 }
11584 */
11585
4/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2666214 times.
✓ Branch 3 taken 19132 times.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_ENEMIESZAXIS))
11586 {
11587 19132 flip = 0;
11588 19132 int32_t fdiv = frate/4;
11589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19132 times.
19132 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11590
11591
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11592 19132 efrate:((clk>=(frate>>1))?1:0);
11593 19132 shadowtile = wpnsbuf[spr_shadow].tile;
11594
11595
1/2
✓ Branch 0 taken 19132 times.
✗ Branch 1 not taken.
19132 if(get_qr(qr_NEWENEMYTILES))
11596 {
11597 19132 shadowtile+=f2;
11598 19132 }
11599 else
11600 {
11601 shadowtile+=f2?1:0;
11602 }
11603
11604 19132 yofs+=shadowdistance;
11605 19132 yofs+=8;
11606 19132 }
11607
3/4
✓ Branch 0 taken 2600205 times.
✓ Branch 1 taken 85141 times.
✓ Branch 2 taken 2685346 times.
✗ Branch 3 not taken.
2685346 if((dmisc9 == e9tPOLSVOICE || dmisc9==e9tVIRE) && !get_qr(qr_POLVIRE_NO_SHADOW))
11608 {
11609 flip = 0;
11610 int32_t fdiv = frate/4;
11611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
11612
11613 int32_t f2=get_qr(qr_NEWENEMYTILES)?
11614 efrate:((clk>=(frate>>1))?1:0);
11615 shadowtile = wpnsbuf[spr_shadow].tile;
11616
11617 if(get_qr(qr_NEWENEMYTILES))
11618 {
11619 shadowtile+=f2;
11620 }
11621 else
11622 {
11623 shadowtile+=f2?1:0;
11624 }
11625 }
11626
2/2
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 2685204 times.
2685346 if(!shadow_overpit(this))
11627 2685204 enemy::drawshadow(dest, translucent);
11628 2685346 yofs=tempy;
11629 2685346 }
11630
11631 98900 int32_t eStalfos::takehit(weapon *w, weapon* realweap)
11632 {
11633 98900 int32_t wpnId = w->id;
11634 98900 int32_t wpnDir = w->dir;
11635
11636
4/4
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 98324 times.
✓ Branch 2 taken 196 times.
✓ Branch 3 taken 380 times.
98900 if(wpnId==wHammer && shield && (flags & guy_bkshield)
11637
5/8
✓ Branch 0 taken 196 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 119 times.
✓ Branch 5 taken 77 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 77 times.
196 && ((flags&inv_front && wpnDir==(dir^down)) || (flags&inv_back && wpnDir==(dir^up))
11638
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 77 times.
77 || (flags&inv_left && wpnDir==(dir^left)) || (flags&inv_right && wpnDir==(dir^right))))
11639 {
11640 119 shield = false;
11641 119 flags &= ~(inv_left|inv_right|inv_back|inv_front);
11642
11643
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 14 times.
119 if(get_qr(qr_BRKNSHLDTILES))
11644 14 o_tile=s_tile;
11645 119 }
11646
11647 98900 int32_t ret = enemy::takehit(w,realweap);
11648
11649
4/4
✓ Branch 0 taken 12005 times.
✓ Branch 1 taken 86895 times.
✓ Branch 2 taken 10754 times.
✓ Branch 3 taken 1251 times.
98900 if(sclk && dmisc2==e2tSPLITHIT)
11650 1251 sclk+=128; //Fuck these arbitrary values with no explanation. Fuck vires, too. -Z
11651
11652 98900 return ret;
11653 }
11654
11655 649572 void eStalfos::charge_attack()
11656 {
11657
2/2
✓ Branch 0 taken 4921 times.
✓ Branch 1 taken 644651 times.
649572 if(slide())
11658 4921 return;
11659
11660
9/12
✓ Branch 0 taken 644651 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 644651 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 622871 times.
✓ Branch 5 taken 21780 times.
✓ Branch 6 taken 604111 times.
✓ Branch 7 taken 18760 times.
✓ Branch 8 taken 599945 times.
✓ Branch 9 taken 4166 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 599945 times.
644651 if(clk<0 || dir<0 || stunclk || watch || ceiling || frozenclock )
11661 44706 return;
11662
11663
2/2
✓ Branch 0 taken 23890 times.
✓ Branch 1 taken 576055 times.
599945 if(clk3<=0)
11664 {
11665 23890 fix_coords(true);
11666
11667
2/2
✓ Branch 0 taken 6397 times.
✓ Branch 1 taken 17493 times.
23890 if(!dashing)
11668 {
11669 17493 int32_t ldir = lined_up(7,false);
11670
11671
4/4
✓ Branch 0 taken 1774 times.
✓ Branch 1 taken 15719 times.
✓ Branch 2 taken 1497 times.
✓ Branch 3 taken 277 times.
17493 if(ldir!=-1 && canmove(ldir,false))
11672 {
11673 1497 dir=ldir;
11674 1497 dashing=true;
11675 1497 step=zslongToFix(dstep*100)+1;
11676 1497 }
11677 15996 else newdir(4,0,0);
11678 17493 }
11679
11680
2/2
✓ Branch 0 taken 23007 times.
✓ Branch 1 taken 883 times.
23890 if(!canmove(dir,false))
11681 {
11682 883 step=zslongToFix(dstep*100);
11683 883 newdir();
11684 883 dashing=false;
11685 883 }
11686
11687 23890 zfix div = step;
11688
11689
1/2
✓ Branch 0 taken 23890 times.
✗ Branch 1 not taken.
23890 if(div == 0)
11690 div = 1;
11691
11692 23890 clk3=(int32_t)(16.0/div);
11693 23890 return;
11694 }
11695
11696 576055 move(step);
11697 576055 --clk3;
11698 649572 }
11699
11700 472060 void eStalfos::vire_hop()
11701 {
11702 //if ( sclk > 0 ) return; //Don't hop during knockback.
11703
11704 // if(dmisc9!=e9tPOLSVOICE)
11705 // {
11706 // //if( slide() /*sclk!=0*/ && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11707 // if( sclk!=0 && dmisc2==e2tSPLIT) //Vires with split on hit, only! -Z
11708 // return; //the enemy should split if it is sliding!
11709 // //else sclk=0; //might need this here, too. -Z
11710 // }
11711
2/2
✓ Branch 0 taken 199058 times.
✓ Branch 1 taken 273002 times.
472060 if(dmisc9!=e9tPOLSVOICE)
11712 {
11713
2/2
✓ Branch 0 taken 193681 times.
✓ Branch 1 taken 5377 times.
199058 if(sclk!=0)
11714 {
11715
2/2
✓ Branch 0 taken 1534 times.
✓ Branch 1 taken 3843 times.
5377 if (dmisc2==e2tSPLITHIT) return;
11716 //return;
11717 3843 }
11718 197524 }
11719 273002 else sclk=0;
11720
11721
8/12
✓ Branch 0 taken 470526 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 470526 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 462011 times.
✓ Branch 5 taken 8515 times.
✓ Branch 6 taken 446955 times.
✓ Branch 7 taken 15056 times.
✓ Branch 8 taken 446955 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 446955 times.
470526 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
11722 23571 return;
11723
11724 446955 int32_t jump_width = (dmisc9==e9tPOLSVOICE) ? 2 : 1;
11725 446955 int32_t jump_height = (dmisc9==e9tPOLSVOICE) ? 27 : 16;
11726
11727 446955 y=floor_y;
11728
11729
2/2
✓ Branch 0 taken 432185 times.
✓ Branch 1 taken 14770 times.
446955 if(clk3<=0)
11730 {
11731 14770 fix_coords();
11732
11733 //z=0;
11734 //if we're not in the middle of a jump or if we can't complete the current jump in the current direction
11735 //if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && isOnSideviewPlatform()))
11736
9/10
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
✓ Branch 2 taken 2542 times.
✓ Branch 3 taken 329 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 2448 times.
✓ Branch 6 taken 42 times.
✓ Branch 7 taken 52 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 42 times.
14770 if(clk2<=0 || !canmove(dir,(zfix)1,spw_floater,false) || (isSideViewGravity() && (isOnSideviewPlatform() || !(moveflags & FLAG_OBEYS_GRAV)))) //Vires in old quests
11737 12322 newdir(rate,homing,dmisc9==e9tPOLSVOICE ? spw_floater : spw_none);
11738
11739
2/2
✓ Branch 0 taken 2871 times.
✓ Branch 1 taken 11899 times.
14770 if(clk2<=0)
11740 {
11741 //z=0;
11742
6/6
✓ Branch 0 taken 10893 times.
✓ Branch 1 taken 1006 times.
✓ Branch 2 taken 10646 times.
✓ Branch 3 taken 247 times.
✓ Branch 4 taken 7845 times.
✓ Branch 5 taken 2801 times.
11899 if(!canmove(dir,(zfix)2,spw_none,false) || m_walkflag(x,y,spw_none, dir) || (zc_oldrand()&15)>=hrate)
11743 {
11744
11745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9098 times.
9098 clk2=(wpn==ewBrang ? 1 : int32_t((16.0*jump_width)/step.getFloat()));
11746 /*if (dmisc9==e9tPOLSVOICE )
11747 {
11748 zprint2("polsvoice jump_width is: %d\n", jump_width);
11749 zprint2("polsvoice raw step is: %d\n", step);
11750 zprint2("polsvoice step.getInt() is: %d\n", step.getInt());
11751 zprint2("setting clk2 on polsvoice to: %d\n", clk2);
11752 }
11753 else
11754 {
11755 zprint2("vire jump_width is: %d\n", jump_width);
11756 zprint2("vire raw step is: %d\n", step);
11757 zprint2("vire step.getInt() is: %d\n", step.getInt());
11758 zprint2("setting clk2 on vire to: %d\n", clk2);
11759 }
11760 */
11761 9098 }
11762 11899 }
11763
11764
4/4
✓ Branch 0 taken 6207 times.
✓ Branch 1 taken 8563 times.
✓ Branch 2 taken 2801 times.
✓ Branch 3 taken 3406 times.
14770 if(dmisc9!=e9tPOLSVOICE && dir>=left) //if we're moving left or right
11765 {
11766 3406 clk2=int32_t((16.0*jump_width)/step.getFloat());
11767 3406 }
11768
11769 14770 clk3=int32_t(16.0/step.getFloat());
11770 14770 }
11771
11772 446955 --clk3;
11773
11774
3/4
✓ Branch 0 taken 185954 times.
✓ Branch 1 taken 261001 times.
✓ Branch 2 taken 185954 times.
✗ Branch 3 not taken.
446955 if(dmisc9==e9tPOLSVOICE || clk2>0)
11775 446955 move(step);
11776
11777 446955 floor_y=y;
11778 446955 clk2--;
11779
11780 //if we're in the middle of a jump
11781
6/6
✓ Branch 0 taken 350625 times.
✓ Branch 1 taken 96330 times.
✓ Branch 2 taken 148718 times.
✓ Branch 3 taken 201907 times.
✓ Branch 4 taken 67317 times.
✓ Branch 5 taken 81401 times.
446955 if(clk2>0 && (dir>=left || dmisc9==e9tPOLSVOICE))
11782 {
11783 269224 int32_t h = fixtoi(fixsin(itofix(clk2*128*step/(16*jump_width)))*jump_height);
11784
11785
4/4
✓ Branch 0 taken 97084 times.
✓ Branch 1 taken 172140 times.
✓ Branch 2 taken 6151 times.
✓ Branch 3 taken 90933 times.
269224 if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11786 {
11787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 90933 times.
90933 if (moveflags & FLAG_USE_FAKE_Z) fakez=h;
11788 90933 else z=h;
11789 90933 }
11790 else
11791 {
11792 //y+=fixtoi(fixsin(itofix((clk2+1)*128*step/(16*jump_width)))*jump_height);
11793 //y-=h;
11794 178291 y=floor_y-h;
11795 178291 shadowdistance=h;
11796 }
11797 269224 }
11798 else
11799 177731 shadowdistance = 0;
11800 472060 }
11801
11802 51 void eStalfos::eathero()
11803 {
11804
5/8
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 32 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 32 times.
51 if(!hashero && Hero.getEaten()==0 && Hero.getAction() != hopping && Hero.getAction() != swimming)
11805 {
11806 32 hashero=true;
11807 32 y=floor_y;
11808 32 z=0;
11809
11810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(Hero.isSwimming())
11811 {
11812 Hero.setX(x);
11813 Hero.setY(y);
11814 }
11815 else
11816 {
11817 32 x=Hero.getX();
11818 32 y=Hero.getY();
11819 }
11820
11821 32 clk2=0;
11822 32 }
11823 51 }
11824
11825 983776 bool eStalfos::WeaponOut()
11826 {
11827
2/2
✓ Branch 0 taken 1749223 times.
✓ Branch 1 taken 412425 times.
2161648 for(int32_t i=0; i<Ewpns.Count(); i++)
11828 {
11829
3/4
✓ Branch 0 taken 571351 times.
✓ Branch 1 taken 1177872 times.
✓ Branch 2 taken 571351 times.
✗ Branch 3 not taken.
1749223 if(((weapon*)Ewpns.spr(i))->parentid==getUID() && Ewpns.spr(i)->id==ewBrang)
11830 {
11831 571351 return true;
11832 }
11833
11834 /*if (bgsfx > 0 && guys.idCount(id) < 2) // count self
11835 stop_sfx(bgsfx);
11836 */
11837 1177872 }
11838
11839 412425 return false;
11840 983776 }
11841
11842 207899 void eStalfos::KillWeapon()
11843 {
11844
2/2
✓ Branch 0 taken 207899 times.
✓ Branch 1 taken 188444 times.
396343 for(int32_t i=0; i<Ewpns.Count(); i++)
11845 {
11846
4/4
✓ Branch 0 taken 159094 times.
✓ Branch 1 taken 29350 times.
✓ Branch 2 taken 158567 times.
✓ Branch 3 taken 527 times.
188444 if(((weapon*)Ewpns.spr(i))->type==misc && Ewpns.spr(i)->id==ewBrang)
11847 {
11848 //only kill this Goriya's boomerang -DD
11849
2/2
✓ Branch 0 taken 293 times.
✓ Branch 1 taken 234 times.
527 if(((weapon *)Ewpns.spr(i))->parentid == getUID())
11850 {
11851 234 Ewpns.del(i);
11852 234 }
11853 527 }
11854 188444 }
11855
11856
4/4
✓ Branch 0 taken 17536 times.
✓ Branch 1 taken 190363 times.
✓ Branch 2 taken 8819 times.
✓ Branch 3 taken 8717 times.
207899 if(wpn==ewBrang && !Ewpns.idCount(ewBrang))
11857 {
11858 8819 stop_sfx(WAV_BRANG);
11859 8819 }
11860 207899 }
11861
11862 void eStalfos::break_shield()
11863 {
11864 if(!shield)
11865 return;
11866
11867 flags&=~(inv_front | inv_back | inv_left | inv_right);
11868 shield=false;
11869
11870 if(get_qr(qr_BRKNSHLDTILES))
11871 o_tile=s_tile;
11872 }
11873
11874 6621 eKeese::eKeese(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
11875 6621 {
11876
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 dir=(zc_oldrand()&7)+8;
11877
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 step=0;
11878 6621 movestatus=1;
11879
3/4
✓ Branch 0 taken 5596 times.
✓ Branch 1 taken 1025 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5596 times.
6621 if (dmisc1 != 1 && dmisc19 > 0)
11880 {
11881 step = dmisc19/100.0;
11882 movestatus = 1;
11883 }
11884
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if (dmisc1 == 2) movestatus=2;
11885 6621 c=0;
11886 6621 SIZEflags = d->SIZEflags;
11887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) ) hxofs=2;
11888
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
11889
11890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_WIDTH) ) hit_width=12;
11891
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
11892
11893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) ) hyofs=4;
11894
1/2
✓ Branch 0 taken 6621 times.
✗ Branch 1 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
11895
11896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( !(SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) ) hit_height=8;
11897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
11898
11899
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
11900 //al_trace("->txsz:%i\n", d->txsz); Verified that this is setting the value. -Z
11901 // al_trace("Enemy txsz:%i\n", txsz);
11902
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
11903
11904
11905
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
11906
11907
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
11908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
11909 {
11910 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
11911 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
11912 }
11913
11914
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6621 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6621 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
11915 6621 clk4=0;
11916 //nets;
11917 6621 dummy_int[1]=0;
11918 6621 }
11919
11920 1835461 bool eKeese::animate(int32_t index)
11921 {
11922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1835461 times.
1835461 if(switch_hooked) return enemy::animate(index);
11923
2/4
✓ Branch 0 taken 1835461 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1835461 times.
1835461 if(fallclk||drownclk) return enemy::animate(index);
11924
2/2
✓ Branch 0 taken 68910 times.
✓ Branch 1 taken 1766551 times.
1835461 if(dying)
11925 68910 return Dead(index);
11926
11927
2/2
✓ Branch 0 taken 15740 times.
✓ Branch 1 taken 1750811 times.
1766551 if(clk==0)
11928 {
11929 15740 removearmos(x,y,ffcactivated);
11930 15740 }
11931
11932
2/2
✓ Branch 0 taken 382128 times.
✓ Branch 1 taken 1384423 times.
1766551 if(dmisc1 == 1) //Walk style. 0 is keese, 1 is bat.
11933 {
11934 382128 floater_walk(rate,hrate,dstep/100,(zfix)0,10,dmisc16,dmisc17);
11935 382128 }
11936 else
11937 {
11938
1/2
✓ Branch 0 taken 1384423 times.
✗ Branch 1 not taken.
1384423 if (dmisc18) floater_walk(rate,hrate,dstep/100,dmisc18/100.0,-1,dmisc16,dmisc17);
11939 1384423 else floater_walk(rate,hrate,dstep/100,dstep/1000,10,dmisc16,dmisc17);
11940 }
11941
11942
2/2
✓ Branch 0 taken 35781 times.
✓ Branch 1 taken 1730770 times.
1766551 if(dmisc2 == e2tKEESETRIB)
11943 {
11944
3/4
✓ Branch 0 taken 35781 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35710 times.
✓ Branch 3 taken 71 times.
35781 if(++clk4==(dmisc20>0?dmisc20:256))
11945 {
11946
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 53 times.
71 if(!m_walkflag(x,y,0, dir))
11947 {
11948 53 int32_t kids = guys.Count();
11949 53 bool success = false;
11950 53 int32_t id2=dmisc3;
11951 53 success = 0 != addenemy((zfix)x,(zfix)y,id2,-24);
11952
11953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if(success)
11954 {
11955
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(itemguy) // Hand down the carried item
11956 {
11957 guycarryingitem = guys.Count()-1;
11958 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
11959 itemguy = false;
11960 }
11961
11962 53 ((enemy*)guys.spr(kids))->count_enemy = count_enemy;
11963 53 }
11964
11965 53 stop_bgsfx(index);
11966 53 return true;
11967 }
11968 else
11969 {
11970 18 clk4=0;
11971 }
11972 18 }
11973 35728 }
11974 // Keese Tribbles stay on the ground, so there's no problem when they transform.
11975
3/4
✓ Branch 0 taken 483168 times.
✓ Branch 1 taken 1247602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 483168 times.
1730770 else if(get_qr(qr_ENEMIESZAXIS) && !(isSideViewGravity()))
11976 {
11977
1/2
✓ Branch 0 taken 483168 times.
✗ Branch 1 not taken.
483168 if (get_qr(qr_OLD_KEESE_Z_AXIS))
11978 {
11979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 483168 times.
483168 if (moveflags & FLAG_USE_FAKE_Z)
11980 {
11981 fakez=int32_t(step/zslongToFix(dstep*100));
11982 // Some variance in keese flight heights when away from Hero
11983 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11984
11985 }
11986 else
11987 {
11988 483168 z=int32_t(step/zslongToFix(dstep*100));
11989 // Some variance in keese flight heights when away from Hero
11990
2/2
✓ Branch 0 taken 392481 times.
✓ Branch 1 taken 90687 times.
483168 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-128)/10));
11991 }
11992 483168 }
11993 else
11994 {
11995 if (moveflags & FLAG_USE_FAKE_Z)
11996 {
11997 fakez=int32_t(step/zslongToFix(dstep*100));
11998 // Some variance in keese flight heights when away from Hero
11999 fakez+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12000
12001 }
12002 else
12003 {
12004 z=int32_t(step/zslongToFix(dstep*100));
12005 // Some variance in keese flight heights when away from Hero
12006 z+=int32_t(step*zc_max(0_zf,(distance(x,y,HeroX(),HeroY())-40)/4));
12007 }
12008 }
12009 483168 }
12010
12011 1766498 return enemy::animate(index);
12012 1835461 }
12013
12014 561528 void eKeese::drawshadow(BITMAP *dest, bool translucent)
12015 {
12016 561528 int32_t tempy=yofs;
12017 561528 flip = 0;
12018 561528 shadowtile = wpnsbuf[spr_shadow].tile+posframe;
12019
12020
2/2
✓ Branch 0 taken 214011 times.
✓ Branch 1 taken 347517 times.
561528 yofs+=zc_min(int32_t(step/zslongToFix(dstep*10)), 8);
12021
2/2
✓ Branch 0 taken 302522 times.
✓ Branch 1 taken 259006 times.
561528 if(!get_qr(qr_ENEMIESZAXIS))
12022 {
12023 259006 yofs+=int32_t(step/zslongToFix(dstep*10));
12024 259006 }
12025
12026
6/6
✓ Branch 0 taken 557934 times.
✓ Branch 1 taken 3594 times.
✓ Branch 2 taken 302522 times.
✓ Branch 3 taken 255412 times.
✓ Branch 4 taken 294452 times.
✓ Branch 5 taken 8070 times.
561528 if(!shadow_overpit(this) && (!get_qr(qr_ENEMIESZAXIS) || step > 0))
12027 549864 enemy::drawshadow(dest, translucent);
12028 561528 yofs=tempy;
12029 561528 }
12030
12031 4144206 void eKeese::draw(BITMAP *dest)
12032 {
12033 4144206 update_enemy_frame();
12034 4144206 enemy::draw(dest);
12035 4144206 }
12036
12037 11346 void eWizzrobe::submerge(bool set)
12038 {
12039
2/2
✓ Branch 0 taken 11318 times.
✓ Branch 1 taken 28 times.
11346 if(get_qr(qr_OLD_WIZZROBE_SUBMERGING))
12040 {
12041 11318 hxofs = set?1000:0;
12042 11318 return;
12043 }
12044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28 times.
28 if(submerged == set) return;
12045 28 submerged = set;
12046
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 14 times.
28 if(set)
12047 14 hxofs+=1000;
12048 14 else hxofs -= 1000;
12049 11346 }
12050 2150 eWizzrobe::eWizzrobe(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12051 2150 {
12052 2150 hxofs = 0;
12053 2150 submerged = false;
12054
2/2
✓ Branch 0 taken 920 times.
✓ Branch 1 taken 1230 times.
2150 switch(dmisc1)
12055 {
12056 case 0:
12057
1/2
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
1230 submerge(true);
12058 1230 fading=fade_invisible;
12059 // Set clk to just before the 'reappear' threshold
12060
6/10
✓ Branch 0 taken 1230 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1230 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 960 times.
✓ Branch 5 taken 270 times.
✓ Branch 6 taken 960 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 270 times.
✗ Branch 9 not taken.
1230 clk=zc_min(clk+(146+zc_max(0,dmisc5))+14,(146+zc_max(0,dmisc5))-1);
12061 1230 break;
12062
12063 default:
12064 920 dir=(loadside==right)?right:left;
12065 920 misc=-3;
12066 920 break;
12067 }
12068
12069 //netst+2880;
12070 2150 charging=false;
12071 2150 firing=false;
12072 2150 fclk=0;
12073
2/2
✓ Branch 0 taken 1230 times.
✓ Branch 1 taken 920 times.
2150 if(!dmisc1) frate=1200+146; //1200 = 20 seconds
12074 2150 SIZEflags = d->SIZEflags;
12075
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && d->txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12076 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12077 // al_trace("Enemy txsz:%i\n", txsz);
12078
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && d->tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12079
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && d->hxsz >= 0 ) hit_width = d->hxsz;
12080
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && d->hysz >= 0 ) hit_height = d->hysz;
12081
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && d->hzsz >= 0 ) hzsz = d->hzsz;
12082
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 )
12083 {
12084 hxofs = (submerged?hxofs:0)+d->hxofs;
12085 }
12086
1/2
✓ Branch 0 taken 2150 times.
✗ Branch 1 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12087 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12088
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12090 {
12091 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12092 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12093 }
12094
12095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2150 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2150 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
12096 2150 }
12097
12098 1015605 bool eWizzrobe::animate(int32_t index)
12099 {
12100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015605 times.
1015605 if(switch_hooked) return enemy::animate(index);
12101
2/4
✓ Branch 0 taken 1015605 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1015605 times.
1015605 if(fallclk||drownclk) return enemy::animate(index);
12102
2/2
✓ Branch 0 taken 21786 times.
✓ Branch 1 taken 993819 times.
1015605 if(dying)
12103 {
12104 21786 return Dead(index);
12105 }
12106
12107
2/2
✓ Branch 0 taken 962127 times.
✓ Branch 1 taken 31692 times.
993819 if(clk==0)
12108 {
12109 31692 removearmos(x,y,ffcactivated);
12110 31692 }
12111
12112
2/2
✓ Branch 0 taken 502494 times.
✓ Branch 1 taken 491325 times.
993819 if(dmisc1) // Floating
12113 {
12114 502494 wizzrobe_attack();
12115 502494 }
12116 else // Teleporting
12117 {
12118
5/6
✓ Branch 0 taken 485972 times.
✓ Branch 1 taken 5353 times.
✓ Branch 2 taken 2710 times.
✓ Branch 3 taken 483262 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2710 times.
491325 if(watch || (!get_qr(qr_WIZZROBES_DONT_OBEY_STUN) && stunclk))
12119 {
12120 5353 fading=0;
12121 5353 submerge(false);
12122 5353 solid_update(false);
12123 5353 }
12124
8/8
✓ Branch 0 taken 469803 times.
✓ Branch 1 taken 2887 times.
✓ Branch 2 taken 2507 times.
✓ Branch 3 taken 2430 times.
✓ Branch 4 taken 2393 times.
✓ Branch 5 taken 2075 times.
✓ Branch 6 taken 2001 times.
✓ Branch 7 taken 1876 times.
485972 else switch(clk)
12125 {
12126 case 0:
12127
2/2
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 2406 times.
2887 if(!dmisc2)
12128 {
12129 // Wizzrobe Misc4 controls whether wizzrobes can teleport on top of solid combos,
12130 // but should not appear on dungeon walls.
12131
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 1997 times.
2406 if ( FFCore.getQuestHeaderInfo(vZelda) <= 0x190 ) place_on_axis(true, false); //1.84, and probably 1.90 wizzrobes should NEVER appear in dungeon walls.-Z (1.84 confirmed, 15th January, 2019 by Chris Miller).
12132
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1925 times.
1997 else if (editorflags&ENEMY_FLAG5)
12133 {
12134 //2.10 Windrobe
12135 //randomise location and face Hero
12136 72 int32_t t=0;
12137 72 bool placed=false;
12138
12139
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 106 times.
✓ Branch 3 taken 72 times.
178 while(!placed && t<160)
12140 {
12141
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 55 times.
106 if(isdungeon())
12142 {
12143 51 x=((zc_oldrand()%12)+2)*16;
12144 51 y=((zc_oldrand()%7)+2)*16;
12145 51 }
12146 else
12147 {
12148 55 x=((zc_oldrand()%14)+1)*16;
12149 55 y=((zc_oldrand()%9)+1)*16;
12150 }
12151
12152
6/6
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 78 times.
✓ Branch 2 taken 62 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 34 times.
✓ Branch 5 taken 72 times.
184 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12153 {
12154 72 placed=true;
12155 72 }
12156
12157 106 ++t;
12158 }
12159
12160
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 46 times.
72 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12161 {
12162
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 5 times.
26 if(y<Hero.getY())
12163 {
12164 21 dir=down;
12165 21 }
12166 else
12167 {
12168 5 dir=up;
12169 }
12170 26 }
12171 else
12172 {
12173
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 25 times.
46 if(x<Hero.getX())
12174 {
12175 25 dir=right;
12176 25 }
12177 else
12178 {
12179 21 dir=left;
12180 }
12181 }
12182
12183
1/2
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
72 if(!placed) // can't place him, he's gone
12184 return true;
12185
12186
12187 //wizzrobe_attack(); //Complaint about 2.10 Windrobes not behaving as they did in 2.10. Let's try it this way. -Z
12188 //wizzrobe_attack_for_real(); //doing this makes them fire twice. The rest is correct.
12189 72 }
12190 1925 else place_on_axis(true, dmisc4!=0);
12191 2406 }
12192 else
12193 {
12194 481 int32_t t=0;
12195 481 bool placed=false;
12196
12197
4/4
✓ Branch 0 taken 481 times.
✓ Branch 1 taken 641 times.
✓ Branch 2 taken 641 times.
✓ Branch 3 taken 481 times.
1122 while(!placed && t<160)
12198 {
12199
2/2
✓ Branch 0 taken 624 times.
✓ Branch 1 taken 17 times.
641 if(isdungeon())
12200 {
12201 624 x=((zc_oldrand()%12)+2)*16;
12202 624 y=((zc_oldrand()%7)+2)*16;
12203 624 }
12204 else
12205 {
12206 17 x=((zc_oldrand()%14)+1)*16;
12207 17 y=((zc_oldrand()%9)+1)*16;
12208 }
12209
12210
6/6
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 554 times.
✓ Branch 2 taken 389 times.
✓ Branch 3 taken 165 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 481 times.
1195 if(!m_walkflag(x,y,spw_door, dir)&&((abs(x-Hero.getX())>=32)||(abs(y-Hero.getY())>=32)))
12211 {
12212 481 placed=true;
12213 481 }
12214
12215 641 ++t;
12216 }
12217
12218
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 322 times.
481 if(abs(x-Hero.getX())<abs(y-Hero.getY()))
12219 {
12220
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 62 times.
159 if(y<Hero.getY())
12221 {
12222 97 dir=down;
12223 97 }
12224 else
12225 {
12226 62 dir=up;
12227 }
12228 159 }
12229 else
12230 {
12231
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 156 times.
322 if(x<Hero.getX())
12232 {
12233 166 dir=right;
12234 166 }
12235 else
12236 {
12237 156 dir=left;
12238 }
12239 }
12240
12241
1/2
✓ Branch 0 taken 481 times.
✗ Branch 1 not taken.
481 if(!placed) // can't place him, he's gone
12242 return true;
12243 }
12244
12245 2887 fading=fade_flicker;
12246 2887 submerge(false);
12247 2887 solid_update(false);
12248 2887 break;
12249
12250 case 64:
12251 2507 fading=0;
12252 2507 charging=true;
12253 2507 break;
12254
12255 case 73:
12256 2430 charging=false;
12257 2430 firing=40;
12258 2430 break;
12259
12260 case 83:
12261 2393 wizzrobe_attack_for_real();
12262 2393 break;
12263
12264 case 119:
12265 2075 firing=false;
12266 2075 charging=true;
12267 2075 break;
12268
12269 case 128:
12270 2001 fading=fade_flicker;
12271 2001 charging=false;
12272 2001 break;
12273
12274 case 146:
12275 1876 fading=fade_invisible;
12276 1876 submerge(true);
12277 1876 solid_update(false);
12278
12279 [[fallthrough]];
12280 default:
12281
3/4
✓ Branch 0 taken 471679 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 468788 times.
✓ Branch 3 taken 2891 times.
471679 if(clk>=(146+zc_max(0,dmisc5)))
12282 2891 clk=-1;
12283
12284 471679 break;
12285 }
12286 }
12287
12288 993819 return enemy::animate(index);
12289 1015605 }
12290
12291 3874 void eWizzrobe::wizzrobe_attack_for_real()
12292 {
12293
1/2
✓ Branch 0 taken 3874 times.
✗ Branch 1 not taken.
3874 if(wpn==0) // Edited enemies
12294 return;
12295
12296
2/2
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 3069 times.
3874 if(dmisc2 == 0) //normal weapon
12297 {
12298 3069 addEwpn(x,y,z,wpn,0,wdp,dir,getUID(), 0, fakez);
12299 3069 sfx(WAV_WAND,pan(int32_t(x)));
12300 3069 }
12301
2/2
✓ Branch 0 taken 355 times.
✓ Branch 1 taken 450 times.
805 else if(dmisc2 == 1) // ring of fire
12302 {
12303 355 addEwpn(x,y,z,wpn,0,wdp,up,getUID(), 0, fakez);
12304 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12305 355 addEwpn(x,y,z,wpn,0,wdp,down,getUID(), 0, fakez);
12306 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12307 355 addEwpn(x,y,z,wpn,0,wdp,left,getUID(), 0, fakez);
12308 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12309 355 addEwpn(x,y,z,wpn,0,wdp,right,getUID(), 0, fakez);
12310 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12311 355 addEwpn(x,y,z,wpn,0,wdp,l_up,getUID(), 0, fakez);
12312 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12313 355 addEwpn(x,y,z,wpn,0,wdp,r_up,getUID(), 0, fakez);
12314 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12315 355 addEwpn(x,y,z,wpn,0,wdp,l_down,getUID(), 0, fakez);
12316 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12317 355 addEwpn(x,y,z,wpn,0,wdp,r_down,getUID(), 0, fakez);
12318 355 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
12319 355 sfx(WAV_FIRE,pan(int32_t(x)));
12320
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 283 times.
355 if (get_qr(qr_8WAY_SHOT_SFX)) sfx(WAV_FIRE,pan(int32_t(x)));
12321 else
12322 {
12323
2/18
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 264 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
283 switch(wpn)
12324 {
12325 19 case ewFireball: sfx(40,pan(int32_t(x))); break;
12326
12327 case ewArrow: sfx(1,pan(int32_t(x))); break; //Ghost.zh has 0?
12328 case ewBrang: sfx(4,pan(int32_t(x))); break; //Ghost.zh has 0?
12329 case ewSword: sfx(20,pan(int32_t(x))); break; //Ghost.zh has 0?
12330 case ewRock: sfx(51,pan(int32_t(x))); break;
12331 case ewMagic: sfx(32,pan(int32_t(x))); break;
12332 case ewBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12333 case ewSBomb: sfx(3,pan(int32_t(x))); break; //Ghost.zh has 0?
12334 case ewLitBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12335 case ewLitSBomb: sfx(21,pan(int32_t(x))); break; //Ghost.zh has 0?
12336 case ewFireTrail: sfx(13,pan(int32_t(x))); break;
12337 264 case ewFlame: sfx(13,pan(int32_t(x))); break;
12338 case ewWind: sfx(32,pan(int32_t(x))); break;
12339 case ewFlame2: sfx(13,pan(int32_t(x))); break;
12340 case ewFlame2Trail: sfx(13,pan(int32_t(x))); break;
12341 case ewIce: sfx(44,pan(int32_t(x))); break;
12342 case ewFireball2: sfx(40,pan(int32_t(x))); break; //fireball (rising)
12343 default: sfx(WAV_FIRE,pan(int32_t(x))); break;
12344
12345 }
12346 }
12347 355 }
12348
2/2
✓ Branch 0 taken 436 times.
✓ Branch 1 taken 14 times.
450 else if(dmisc2==2) // summons specific enemy
12349 {
12350 436 int32_t bc=0;
12351
12352
2/2
✓ Branch 0 taken 5394 times.
✓ Branch 1 taken 436 times.
5830 for(int32_t gc=0; gc<guys.Count(); gc++)
12353 {
12354
2/2
✓ Branch 0 taken 2590 times.
✓ Branch 1 taken 2804 times.
5394 if((((enemy*)guys.spr(gc))->id) == dmisc3)
12355 {
12356 2804 ++bc;
12357 2804 }
12358 5394 }
12359
12360
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 428 times.
436 if(bc<=40)
12361 {
12362 428 int32_t kids = guys.Count();
12363 428 int32_t bats=(zc_oldrand()%3)+1;
12364
12365
2/2
✓ Branch 0 taken 868 times.
✓ Branch 1 taken 428 times.
1296 for(int32_t i=0; i<bats; i++)
12366 {
12367 // Summon bats (or anything)
12368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 868 times.
868 if(addchild(x,y,dmisc3,-10, this->script_UID))
12369 868 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12370 868 }
12371
12372 428 sfx(WAV_FIRE,pan(int32_t(x)));
12373 428 }
12374 436 }
12375
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 else if(dmisc2==3) //summon from layer
12376 {
12377
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count_layer_enemies()==0)
12378 {
12379 return;
12380 }
12381
12382 14 int32_t kids = guys.Count();
12383
12384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(kids<200)
12385 {
12386 14 int32_t newguys=(zc_oldrand()%3)+1;
12387 14 bool summoned=false;
12388
12389
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 14 times.
39 for(int32_t i=0; i<newguys; i++)
12390 {
12391 25 int32_t id2=vbound(random_layer_enemy(),eSTART,eMAXGUYS-1);
12392 25 int32_t x2=0;
12393 25 int32_t y2=0;
12394
12395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
27 for(int32_t k=0; k<20; ++k)
12396 {
12397 27 x2=16*((zc_oldrand()%12)+2);
12398 27 y2=16*((zc_oldrand()%7)+2);
12399
12400
5/6
✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 25 times.
54 if(!m_walkflag(x2,y2,0, dir) && (abs(x2-Hero.getX())>=32 || abs(y2-Hero.getY())>=32))
12401 {
12402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
25 if(addchild(x2,y2,get_qr(qr_ENEMIESZAXIS) ? 64 : 0,id2,-10, this->script_UID))
12403 {
12404 25 ((enemy*)guys.spr(kids+i))->count_enemy = false;
12405
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
25 if (get_qr(qr_ENEMIESZAXIS) && (((enemy*)guys.spr(kids+i))->moveflags & FLAG_USE_FAKE_Z))
12406 {
12407 ((enemy*)guys.spr(kids+i))->fakez = 64;
12408 ((enemy*)guys.spr(kids+i))->z = 0;
12409 }
12410 25 }
12411
12412 25 summoned=true;
12413 25 break;
12414 }
12415 2 }
12416 25 }
12417
12418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(summoned)
12419 {
12420 14 sfx(get_qr(qr_MORESOUNDS) ? WAV_ZN1SUMMON : WAV_FIRE,pan(int32_t(x)));
12421 14 }
12422 14 }
12423 14 }
12424 3874 }
12425
12426
12427 502494 void eWizzrobe::wizzrobe_attack()
12428 {
12429
9/12
✓ Branch 0 taken 487591 times.
✓ Branch 1 taken 14903 times.
✓ Branch 2 taken 487591 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 468976 times.
✓ Branch 5 taken 18615 times.
✓ Branch 6 taken 466825 times.
✓ Branch 7 taken 2151 times.
✓ Branch 8 taken 466825 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 466825 times.
502494 if(clk<0 || dying || stunclk || watch || ceiling || frozenclock)
12430 35669 return;
12431
12432
3/8
✓ Branch 0 taken 448202 times.
✓ Branch 1 taken 18623 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 448202 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
466825 if(clk3<=0 || ((clk3&31)==0 && !canmove(dir,(zfix)1,spw_door,false) && !misc))
12433 {
12434 18623 fix_coords();
12435
12436
5/5
✓ Branch 0 taken 2316 times.
✓ Branch 1 taken 603 times.
✓ Branch 2 taken 8722 times.
✓ Branch 3 taken 4845 times.
✓ Branch 4 taken 2137 times.
18623 switch(misc)
12437 {
12438 case 1: //walking
12439
2/2
✓ Branch 0 taken 3698 times.
✓ Branch 1 taken 1147 times.
4845 if(!m_walkflag(x,y,spw_door, dir))
12440 1147 misc=0;
12441 else
12442 {
12443 3698 clk3=16;
12444
12445
2/2
✓ Branch 0 taken 3185 times.
✓ Branch 1 taken 513 times.
3698 if(!canmove(dir,(zfix)1,spw_wizzrobe,false))
12446 {
12447 513 wizzrobe_newdir(0);
12448 513 }
12449 }
12450
12451 4845 break;
12452
12453 case 2: //phasing
12454 {
12455 2137 int32_t jx=x;
12456 2137 int32_t jy=y;
12457 2137 int32_t jdir=-1;
12458
12459
5/5
✓ Branch 0 taken 1083 times.
✓ Branch 1 taken 279 times.
✓ Branch 2 taken 245 times.
✓ Branch 3 taken 264 times.
✓ Branch 4 taken 266 times.
2137 switch(zc_oldrand()&7)
12460 {
12461 case 0:
12462 279 jx-=32;
12463 279 jy-=32;
12464 279 jdir=15;
12465 279 break;
12466
12467 case 1:
12468 245 jx+=32;
12469 245 jy-=32;
12470 245 jdir=9;
12471 245 break;
12472
12473 case 2:
12474 264 jx+=32;
12475 264 jy+=32;
12476 264 jdir=11;
12477 264 break;
12478
12479 case 3:
12480 266 jx-=32;
12481 266 jy+=32;
12482 266 jdir=13;
12483 266 break;
12484 }
12485
12486
10/10
✓ Branch 0 taken 1054 times.
✓ Branch 1 taken 1083 times.
✓ Branch 2 taken 940 times.
✓ Branch 3 taken 114 times.
✓ Branch 4 taken 876 times.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 763 times.
✓ Branch 7 taken 113 times.
✓ Branch 8 taken 633 times.
✓ Branch 9 taken 130 times.
2137 if(jdir>0 && jx>=32 && jx<=208 && jy>=32 && jy<=128)
12487 {
12488 633 misc=3;
12489 633 clk3=32;
12490 633 dir=jdir;
12491 633 break;
12492 }
12493 1504 }
12494 [[fallthrough]];
12495 case 3:
12496 2107 dir&=3;
12497 2107 misc=0;
12498 [[fallthrough]];
12499 case 0:
12500 10829 wizzrobe_newdir(64);
12501 [[fallthrough]];
12502 default:
12503
2/2
✓ Branch 0 taken 11753 times.
✓ Branch 1 taken 1392 times.
13145 if(!canmove(dir,(zfix)1,spw_door,false))
12504 {
12505
2/2
✓ Branch 0 taken 1326 times.
✓ Branch 1 taken 66 times.
1392 if(canmove(dir,(zfix)15,spw_wizzrobe,false))
12506 {
12507 1326 misc=1;
12508 1326 clk3=16;
12509 1326 }
12510 else
12511 {
12512 66 wizzrobe_newdir(64);
12513 66 misc=0;
12514 66 clk3=32;
12515 }
12516 1392 }
12517 else
12518 {
12519 11753 clk3=32;
12520 }
12521
12522 13145 break;
12523 }
12524
12525
2/2
✓ Branch 0 taken 16596 times.
✓ Branch 1 taken 2027 times.
18623 if(misc<0)
12526 2027 ++misc;
12527 18623 }
12528
12529 466825 --clk3;
12530
12531
3/3
✓ Branch 0 taken 98770 times.
✓ Branch 1 taken 332655 times.
✓ Branch 2 taken 35400 times.
466825 switch(misc)
12532 {
12533 case 1:
12534 case 3:
12535 98770 step=1;
12536 98770 break;
12537
12538 case 2:
12539 35400 step=0;
12540 35400 break;
12541
12542 default:
12543 332655 step=0.5;
12544 332655 break;
12545
12546 }
12547
12548 466825 move(step);
12549
12550 // if(d->misc1 && misc<=0 && clk3==28)
12551
5/6
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332655 times.
✓ Branch 3 taken 134170 times.
✓ Branch 4 taken 321156 times.
✓ Branch 5 taken 11499 times.
466825 if(dmisc1 && misc<=0 && clk3==28)
12552 {
12553
2/2
✓ Branch 0 taken 9880 times.
✓ Branch 1 taken 1619 times.
11499 if(dmisc2 != 1)
12554 {
12555
2/2
✓ Branch 0 taken 8754 times.
✓ Branch 1 taken 1126 times.
9880 if(lined_up(8,false) == dir)
12556 {
12557 // addEwpn(x,y,z,wpn,0,wdp,dir,getUID());
12558 // sfx(WAV_WAND,pan(int32_t(x)));
12559 1126 wizzrobe_attack_for_real();
12560 1126 fclk=30;
12561 1126 }
12562 9880 }
12563 else
12564 {
12565
2/2
✓ Branch 0 taken 1264 times.
✓ Branch 1 taken 355 times.
1619 if((zc_oldrand()%500)>=400)
12566 {
12567 355 wizzrobe_attack_for_real();
12568 355 fclk=30;
12569 355 }
12570 }
12571 11499 }
12572
12573
4/4
✓ Branch 0 taken 287050 times.
✓ Branch 1 taken 179775 times.
✓ Branch 2 taken 2200 times.
✓ Branch 3 taken 284850 times.
466825 if(misc==0 && (zc_oldrand()&127)==0)
12574 2200 misc=2;
12575
12576
4/4
✓ Branch 0 taken 37600 times.
✓ Branch 1 taken 429225 times.
✓ Branch 2 taken 35712 times.
✓ Branch 3 taken 1888 times.
466825 if(misc==2 && clk3==4)
12577 1888 fix_coords();
12578
12579
2/4
✓ Branch 0 taken 466825 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 466825 times.
466825 if(!(charging||firing)) //should never be charging or firing for these wizzrobes
12580 {
12581
2/2
✓ Branch 0 taken 424649 times.
✓ Branch 1 taken 42176 times.
466825 if(fclk>0)
12582 {
12583 42176 --fclk;
12584 42176 }
12585 466825 }
12586
12587 502494 }
12588
12589 11408 void eWizzrobe::wizzrobe_newdir(int32_t homing)
12590 {
12591 // Wizzrobes shouldn't move to the edge of the screen;
12592 // if they're already there, they should move toward the center
12593
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11404 times.
11408 if(x<32)
12594 4 dir=right;
12595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(x>=224)
12596 dir=left;
12597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11404 times.
11404 else if(y<32)
12598 dir=down;
12599
1/2
✓ Branch 0 taken 11404 times.
✗ Branch 1 not taken.
11404 else if(y>=144)
12600 dir=up;
12601 else
12602 11404 newdir(4,homing,spw_wizzrobe);
12603 11408 }
12604
12605 1018464 void eWizzrobe::draw(BITMAP *dest)
12606 {
12607 // if(d->misc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk) // phasing
12608
13/14
✓ Branch 0 taken 512388 times.
✓ Branch 1 taken 506076 times.
✓ Branch 2 taken 428953 times.
✓ Branch 3 taken 83435 times.
✓ Branch 4 taken 53103 times.
✓ Branch 5 taken 459285 times.
✓ Branch 6 taken 52418 times.
✓ Branch 7 taken 685 times.
✓ Branch 8 taken 51661 times.
✓ Branch 9 taken 757 times.
✓ Branch 10 taken 49440 times.
✓ Branch 11 taken 2221 times.
✓ Branch 12 taken 49440 times.
✗ Branch 13 not taken.
1018464 if(dmisc1 && (misc==1 || misc==3) && (clk3&1) && hp>0 && !watch && !stunclk && !frozenclock) // phasing
12609 49440 return;
12610
12611 969024 int32_t tempint=dummy_int[1];
12612 969024 bool tempbool1=dummy_bool[1];
12613 969024 bool tempbool2=dummy_bool[2];
12614 969024 dummy_int[1]=fclk;
12615 969024 dummy_bool[1]=charging;
12616 969024 dummy_bool[2]=firing;
12617 969024 update_enemy_frame();
12618 969024 dummy_int[1]=tempint;
12619 969024 dummy_bool[1]=tempbool1;
12620 969024 dummy_bool[2]=tempbool2;
12621 969024 enemy::draw(dest);
12622 1018464 }
12623
12624 /*********************************/
12625 /********** Bosses ***********/
12626 /*********************************/
12627
12628 139 eDodongo::eDodongo(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12629 139 {
12630 139 fading=fade_flash_die;
12631 //nets+5120;
12632
6/8
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 31 times.
✓ Branch 7 taken 3 times.
139 if(dir==down&&y>=128)
12633 {
12634 3 dir=up;
12635 3 }
12636
12637
5/8
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 98 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 41 times.
✗ Branch 7 not taken.
139 if(dir==right&&x>=208)
12638 {
12639 dir=left;
12640 }
12641 139 SIZEflags = d->SIZEflags;
12642
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12643 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12644 // al_trace("Enemy txsz:%i\n", txsz);
12645
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12646
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12647
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12648
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12649
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12650
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12651 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12652
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12654 {
12655 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12656 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12657 }
12658
12659
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 139 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
139 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12660 139 }
12661
12662 94046 bool eDodongo::animate(int32_t index)
12663 {
12664
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94046 times.
94046 if(switch_hooked) return enemy::animate(index);
12665
2/2
✓ Branch 0 taken 3170 times.
✓ Branch 1 taken 90876 times.
94046 if(dying)
12666 {
12667 3170 return Dead(index);
12668 }
12669
12670
2/2
✓ Branch 0 taken 90462 times.
✓ Branch 1 taken 414 times.
90876 if(clk==0)
12671 {
12672 414 removearmos(x,y,ffcactivated);
12673 414 }
12674
12675
2/2
✓ Branch 0 taken 8736 times.
✓ Branch 1 taken 82140 times.
90876 if(clk2) // ate a bomb
12676 {
12677
2/2
✓ Branch 0 taken 8645 times.
✓ Branch 1 taken 91 times.
8736 if(--clk2==0)
12678 91 hp-=misc; // store bomb's power in misc
12679 8736 }
12680 else
12681 82140 constant_walk(rate,homing,spw_clipright);
12682
12683 90876 hit_width = (dir<=down) ? 16 : 32;
12684 // hysz = (dir>=left) ? 16 : 32;
12685
12686 90876 return enemy::animate(index);
12687 94046 }
12688
12689 94037 void eDodongo::draw(BITMAP *dest)
12690 {
12691 94037 tile=o_tile;
12692
12693
2/2
✓ Branch 0 taken 2272 times.
✓ Branch 1 taken 91765 times.
94037 if(clk<0)
12694 {
12695 2272 enemy::drawzcboss(dest);
12696 2272 return;
12697 }
12698
12699 91765 update_enemy_frame();
12700 91765 enemy::drawzcboss(dest);
12701
12702
2/2
✓ Branch 0 taken 37532 times.
✓ Branch 1 taken 54233 times.
91765 if(dummy_int[1]!=0) //additional tiles
12703 {
12704 54233 tile+=dummy_int[1]; //second tile is previous tile
12705 54233 xofs-=16; //new xofs change
12706 54233 enemy::drawzcboss(dest);
12707 54233 xofs+=16;
12708 54233 }
12709
12710 94037 }
12711
12712 6225 int32_t eDodongo::takehit(weapon *w, weapon* realweap)
12713 {
12714 6225 int32_t wpnId = w->id;
12715 6225 int32_t power = w->power;
12716 6225 int32_t wpnx = w->x;
12717 6225 int32_t wpny = w->y;
12718
12719
5/12
✓ Branch 0 taken 6225 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6225 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1749 times.
✓ Branch 5 taken 4476 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1749 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
6225 if(dying || clk<0 || clk2>0 || (superman && !(superman>1 && wpnId==wSBomb)))
12720 4476 return 0;
12721
12722
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 607 times.
✓ Branch 2 taken 1028 times.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 98 times.
1749 switch(wpnId)
12723 {
12724 case wPhantom:
12725 return 0;
12726
12727 case wFire:
12728 case wBait:
12729 case wWhistle:
12730 case wWind:
12731 case wSSparkle:
12732 case wFSparkle:
12733 return 0;
12734
12735 case wLitBomb:
12736 case wLitSBomb:
12737
6/6
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 397 times.
✓ Branch 2 taken 238 times.
✓ Branch 3 taken 369 times.
✓ Branch 4 taken 516 times.
✓ Branch 5 taken 91 times.
607 if(abs(wpnx-((dir==right)?x+16:x)) > 7 || abs(wpny-y) > 7)
12738 516 return 0;
12739
12740 91 clk2=96;
12741 91 misc=power;
12742
12743
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 3 times.
91 if(wpnId==wLitSBomb)
12744 3 item_set=isSBOMB100;
12745
12746 91 return 1;
12747
12748 case wBomb:
12749 case wSBomb:
12750
6/6
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 633 times.
✓ Branch 2 taken 289 times.
✓ Branch 3 taken 739 times.
✓ Branch 4 taken 361 times.
✓ Branch 5 taken 667 times.
1028 if(abs(wpnx-((dir==right)?x+16:x)) > 8 || abs(wpny-y) > 8)
12751 361 return 0;
12752
12753 667 stunclk=160;
12754 667 misc=wpnId; // store wpnId
12755 667 return 1;
12756
12757 case wSword:
12758
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 67 times.
98 if(stunclk)
12759 {
12760 67 sfx(WAV_EHIT,pan(int32_t(x)));
12761 67 hp=0;
12762 67 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12763 67 fading=0; // don't flash
12764 67 return 1;
12765 }
12766
12767 [[fallthrough]];
12768 default:
12769 47 sfx(WAV_CHINK,pan(int32_t(x)));
12770 47 }
12771
12772 47 return 1;
12773 6225 }
12774
12775 2 eDodongo2::eDodongo2(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
12776 2 {
12777 2 fading=fade_flash_die;
12778 //nets+5180;
12779 2 previous_dir=-1;
12780
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==down&&y>=128)
12781 {
12782 dir=up;
12783 }
12784
12785
5/8
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
2 if(dir==right&&x>=208)
12786 {
12787 dir=left;
12788 }
12789 2 SIZEflags = d->SIZEflags;
12790
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
12791 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
12792 // al_trace("Enemy txsz:%i\n", txsz);
12793
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
12794
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
12795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
12796
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
12797
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
12798
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
12799 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
12800
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
12801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
12802 {
12803 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
12804 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
12805 }
12806
12807
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
12808 2 }
12809
12810 848 bool eDodongo2::animate(int32_t index)
12811 {
12812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 848 times.
848 if(switch_hooked) return enemy::animate(index);
12813
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 812 times.
848 if(dying)
12814 {
12815 36 return Dead(index);
12816 }
12817
12818
2/2
✓ Branch 0 taken 808 times.
✓ Branch 1 taken 4 times.
812 if(clk==0)
12819 {
12820 4 removearmos(x,y,ffcactivated);
12821 4 }
12822
12823
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 620 times.
812 if(clk2) // ate a bomb
12824 {
12825
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 2 times.
192 if(--clk2==0)
12826 2 hp-=misc; // store bomb's power in misc
12827 192 }
12828 else
12829 620 constant_walk(rate,homing,spw_clipbottomright);
12830
12831 812 hit_width = (dir<=down) ? 16 : 32;
12832 812 hit_height = (dir>=left) ? 16 : 32;
12833 812 hxofs=(dir>=left)?-8:0;
12834 812 hyofs=(dir<left)?-8:0;
12835
12836 812 return enemy::animate(index);
12837 848 }
12838
12839 848 void eDodongo2::draw(BITMAP *dest)
12840 {
12841
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 818 times.
848 if(clk<0)
12842 {
12843 30 enemy::drawzcboss(dest);
12844 30 return;
12845 }
12846
12847 818 int32_t tempx=xofs;
12848 818 int32_t tempy=yofs;
12849 818 update_enemy_frame();
12850 818 enemy::drawzcboss(dest);
12851 818 tile+=dummy_int[1]; //second tile change
12852 818 xofs+=dummy_int[2]; //new xofs change
12853 818 yofs+=dummy_int[3]; //new yofs change
12854 818 enemy::drawzcboss(dest);
12855 818 xofs=tempx;
12856 818 yofs=tempy;
12857 848 }
12858
12859 165 int32_t eDodongo2::takehit(weapon *w, weapon* realweap)
12860 {
12861 165 int32_t wpnId = w->id;
12862 165 int32_t power = w->power;
12863 165 int32_t wpnx = w->x;
12864 165 int32_t wpny = w->y;
12865
12866
5/8
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 165 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 145 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 20 times.
165 if(dying || clk<0 || clk2>0 || superman)
12867 145 return 0;
12868
12869
4/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
20 switch(wpnId)
12870 {
12871 case wPhantom:
12872 return 0;
12873
12874 case wFire:
12875 case wBait:
12876 case wWhistle:
12877 case wWind:
12878 case wSSparkle:
12879 case wFSparkle:
12880 return 0;
12881
12882 case wLitBomb:
12883 case wLitSBomb:
12884
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
2 switch(dir)
12885 {
12886 case up:
12887 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12888 return 0;
12889
12890 break;
12891
12892 case down:
12893 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12894 return 0;
12895
12896 break;
12897
12898 case left:
12899
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12900 return 0;
12901
12902 2 break;
12903
12904 case right:
12905 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12906 return 0;
12907
12908 break;
12909 }
12910
12911 // if(abs(wpnx-((dir==right)?x+8:(dir==left)?x-8:0)) > 7 || abs(wpny-((dir==down)?y+8:(dir==up)?y-8:0)) > 7)
12912 // return 0;
12913 2 clk2=96;
12914 2 misc=power;
12915
12916
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(wpnId==wLitSBomb)
12917 item_set=isSBOMB100;
12918
12919 2 return 1;
12920
12921 case wBomb:
12922 case wSBomb:
12923
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
✗ Branch 4 not taken.
15 switch(dir)
12924 {
12925 case up:
12926 if(abs(wpnx-x) > 7 || abs(wpny-(y-8)) > 7)
12927 return 0;
12928
12929 break;
12930
12931 case down:
12932 if(abs(wpnx-x) > 7 || abs(wpny-(y+8)) > 7)
12933 return 0;
12934
12935 break;
12936
12937 case left:
12938
2/4
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
15 if(abs(wpnx-(x-8)) > 7 || abs(wpny-y) > 7)
12939 return 0;
12940
12941 15 break;
12942
12943 case right:
12944 if(abs(wpnx-(x+8)) > 7 || abs(wpny-y) > 7)
12945 return 0;
12946
12947 break;
12948 }
12949
12950 15 stunclk=160;
12951 15 misc=wpnId; // store wpnId
12952 15 return 1;
12953
12954 case wSword:
12955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(stunclk)
12956 {
12957 2 sfx(WAV_EHIT,pan(int32_t(x)));
12958 2 hp=0;
12959 2 item_set = (misc==wSBomb) ? isSBOMB100 : isBOMB100;
12960 2 fading=0; // don't flash
12961 2 return 1;
12962 }
12963
12964 [[fallthrough]];
12965 default:
12966 1 sfx(WAV_CHINK,pan(int32_t(x)));
12967 1 }
12968
12969 1 return 1;
12970 165 }
12971
12972 76 eAquamentus::eAquamentus(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)//enemy((zfix)176,(zfix)64,Id,Clk)
12973 76 {
12974 //these are here to bypass compiler warnings about unused arguments
12975
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( !(editorflags & ENEMY_FLAG5) )
12976 {
12977
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 x = dmisc1 ? 64 : 176;
12978
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 y = 64;
12979 76 }
12980 else { x = X; y = Y; }
12981
12982 //nets+5940;
12983
3/4
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 33 times.
76 if(get_qr(qr_NEWENEMYTILES))
12984 {
12985 43 }
12986 else
12987 {
12988
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 7 times.
33 if(dmisc1)
12989 {
12990 7 flip=1;
12991 7 }
12992 }
12993
12994
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76 times.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
12995 76 clk3=32;
12996 76 clk2=0;
12997 76 clk4=clk;
12998 76 dir=left;
12999 76 SIZEflags = d->SIZEflags;
13000
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13001 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13002 // al_trace("Enemy txsz:%i\n", txsz);
13003
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13004
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13005
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13006
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13007
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13008
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13009 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13010
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13012 {
13013 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13014 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13015 }
13016
13017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
76 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13018 76 }
13019
13020 50824 bool eAquamentus::animate(int32_t index)
13021 {
13022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50824 times.
50824 if(switch_hooked) return enemy::animate(index);
13023
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 49558 times.
50824 if(dying)
13024 1266 return Dead(index);
13025
13026 // fbx=x+((id==eRAQUAM)?4:-4);
13027
2/2
✓ Branch 0 taken 49337 times.
✓ Branch 1 taken 221 times.
49558 if(clk==0)
13028 {
13029 221 removearmos(x,y,ffcactivated);
13030 221 }
13031
13032 49558 fbx=x;
13033
13034 /*
13035 if (get_qr(qr_NEWENEMYTILES)&&id==eLAQUAM)
13036 {
13037 fbx+=16;
13038 }
13039 */
13040
2/2
✓ Branch 0 taken 49241 times.
✓ Branch 1 taken 317 times.
49558 if(--clk3==0)
13041 {
13042 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,up+1);
13043 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,0);
13044 // addEwpn(fbx,y,z,ewFireball,0,d->wdp,down+1);
13045 317 addEwpn(fbx,y,z,wpn,2,wdp,up,getUID(), 0, fakez);
13046 317 addEwpn(fbx,y,z,wpn,2,wdp,8,getUID(), 0, fakez);
13047 317 addEwpn(fbx,y,z,wpn,2,wdp,down,getUID(), 0, fakez);
13048 317 sfx(wpnsfx(wpn),pan(int32_t(x)));
13049 317 }
13050
13051
4/4
✓ Branch 0 taken 15161 times.
✓ Branch 1 taken 34397 times.
✓ Branch 2 taken 254 times.
✓ Branch 3 taken 14907 times.
49558 if(clk3<-80 && !(zc_oldrand()&63))
13052 {
13053 254 clk3=32;
13054 254 }
13055
13056
2/2
✓ Branch 0 taken 48766 times.
✓ Branch 1 taken 792 times.
49558 if(!((clk4+1)&63))
13057 {
13058 792 int32_t d2=(zc_oldrand()%3)+1;
13059
13060
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 533 times.
792 if(d2>=left)
13061 {
13062 533 dir=d2;
13063 533 }
13064
13065
2/2
✓ Branch 0 taken 350 times.
✓ Branch 1 taken 442 times.
792 if(dmisc1)
13066 {
13067
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 35 times.
350 if(x<=40)
13068 {
13069 35 dir=right;
13070 35 }
13071
13072
1/2
✓ Branch 0 taken 350 times.
✗ Branch 1 not taken.
350 if(x>=104)
13073 {
13074 dir=left;
13075 }
13076 350 }
13077 else
13078 {
13079
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 14 times.
442 if(x<=136)
13080 {
13081 14 dir=right;
13082 14 }
13083
13084
2/2
✓ Branch 0 taken 420 times.
✓ Branch 1 taken 22 times.
442 if(x>=200)
13085 {
13086 22 dir=left;
13087 22 }
13088 }
13089 792 }
13090
13091
4/4
✓ Branch 0 taken 48440 times.
✓ Branch 1 taken 1118 times.
✓ Branch 2 taken 42352 times.
✓ Branch 3 taken 6088 times.
49558 if(clk4>=-1 && !((clk4+1)&7))
13092 {
13093
2/2
✓ Branch 0 taken 3226 times.
✓ Branch 1 taken 2862 times.
6088 if(dir==left)
13094 {
13095 3226 x-=1;
13096 3226 }
13097 else
13098 {
13099 2862 x+=1;
13100 }
13101 6088 }
13102
13103 49558 clk4=(clk4+1)%256;
13104
13105 49558 return enemy::animate(index);
13106 50824 }
13107
13108 51235 void eAquamentus::draw(BITMAP *dest)
13109 {
13110
2/2
✓ Branch 0 taken 29751 times.
✓ Branch 1 taken 21484 times.
51235 if(get_qr(qr_NEWENEMYTILES))
13111 {
13112 29751 xofs=(dmisc1?-16:0);
13113
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 29751 times.
✓ Branch 2 taken 12244 times.
✓ Branch 3 taken 17507 times.
29751 if ( do_animation ) tile=o_tile+((clk&24)>>2)+(clk3>-32?(clk3>0?40:80):0);
13114
13115
2/2
✓ Branch 0 taken 690 times.
✓ Branch 1 taken 29061 times.
29751 if(dying)
13116 {
13117 690 xofs=0;
13118 690 enemy::draw(dest);
13119 690 }
13120 else
13121 {
13122 29061 drawblock(dest,15);
13123 }
13124 29751 }
13125 else
13126 {
13127 21484 int32_t xblockofs=((dmisc1)?-16:16);
13128 21484 xofs=0;
13129
13130
4/4
✓ Branch 0 taken 20982 times.
✓ Branch 1 taken 502 times.
✓ Branch 2 taken 576 times.
✓ Branch 3 taken 20406 times.
21484 if(clk<0 || dying)
13131 {
13132 1078 enemy::draw(dest);
13133 1078 return;
13134 }
13135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20406 times.
20406 if ( do_animation )
13136 {
13137 // face (0=firing, 2=resting)
13138 20406 tile=o_tile+((clk3>0)?0:2);
13139 20406 enemy::draw(dest);
13140 // tail (
13141 20406 tile=o_tile+((clk&16)?1:3);
13142 20406 xofs=xblockofs;
13143 20406 enemy::draw(dest);
13144 // body
13145 20406 yofs+=16;
13146 20406 xofs=0;
13147 20406 tile=o_tile+((clk&16)?20:22);
13148 20406 enemy::draw(dest);
13149 20406 xofs=xblockofs;
13150 20406 tile=o_tile+((clk&16)?21:23);
13151 20406 enemy::draw(dest);
13152 20406 yofs-=16;
13153 20406 }
13154 else enemy::draw(dest);
13155 }
13156 51235 }
13157
13158 10639 bool eAquamentus::hit(weapon *w)
13159 {
13160
3/6
✓ Branch 0 taken 10639 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10639 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10639 times.
10639 if(!(w->scriptcoldet&1) || w->fallclk || w->drownclk) return false;
13161
13162
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 7833 times.
10639 switch(w->id)
13163 {
13164 case wBeam:
13165 case wRefBeam:
13166 case wMagic:
13167 2806 hit_height=32;
13168 2806 }
13169
13170
4/4
✓ Branch 0 taken 10500 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 8298 times.
✓ Branch 3 taken 2202 times.
10639 bool ret = (dying || hclk>0) ? false : sprite::hit(w);
13171 10639 hit_height=16;
13172 10639 return ret;
13173
13174 10639 }
13175
13176 55 eGohma::eGohma(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) // enemy((zfix)128,(zfix)48,Id,0)
13177 55 {
13178
13179
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( !(editorflags & ENEMY_FLAG5) )
13180 {
13181
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 x = 128;
13182
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 y = 48;
13183 55 }
13184 else { x = X; y = Y; }
13185
13186 55 Clk=Clk;
13187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if(flags & guy_fadeflicker)
13188 {
13189 clk=0;
13190 superman = 1;
13191 fading=fade_flicker;
13192 if (!(editorflags&ENEMY_FLAG3)) count_enemy=false;
13193 }
13194
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 36 times.
55 else if(flags & guy_fadeinstant)
13195 {
13196 36 clk=0;
13197 36 }
13198 55 hxofs=-16;
13199 55 hit_width=48;
13200 55 clk4=0;
13201
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)+1;
13202
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 dir=zc_oldrand()%3+1;
13203 55 SIZEflags = d->SIZEflags;
13204
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13205 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13206 // al_trace("Enemy txsz:%i\n", txsz);
13207
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
13208
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
13209
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
13210
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
55 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
13211
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
13212
1/2
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
13213 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13214
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
13215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13216 {
13217 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
13218 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13219 }
13220
13221
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 55 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
55 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
13222
13223 //nets+5340;
13224 55 }
13225
13226 46569 bool eGohma::animate(int32_t index)
13227 {
13228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46569 times.
46569 if(switch_hooked) return enemy::animate(index);
13229
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 45799 times.
46569 if(dying)
13230 770 return Dead(index);
13231
13232
2/2
✓ Branch 0 taken 45788 times.
✓ Branch 1 taken 11 times.
45799 if(fading)
13233 {
13234
1/2
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
11 if(++clk4 > 60)
13235 {
13236 11 clk4=0;
13237 11 superman=0;
13238 11 fading=0;
13239 11 clk=0;
13240
13241 11 }
13242 else return enemy::animate(index);
13243 11 }
13244
13245
2/2
✓ Branch 0 taken 45583 times.
✓ Branch 1 taken 216 times.
45799 if(clk==0)
13246 {
13247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if (ffcactivated) removearmosffc(ffcactivated-1);
13248 else
13249 {
13250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 removearmos(zc_max(x-16, 0_zf),y);
13251 216 did_armos = false;
13252 216 removearmos(x,y);
13253 216 did_armos = false;
13254
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 removearmos(zc_min(x+16, 255_zf),y);
13255 }
13256 216 }
13257
13258
2/2
✓ Branch 0 taken 45511 times.
✓ Branch 1 taken 288 times.
45799 if(clk<0) return enemy::animate(index);
13259
13260 // Movement clk must be separate from animation clk because of the Clock item
13261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45511 times.
45511 if(!watch)
13262 45511 clk4++;
13263
13264
2/2
✓ Branch 0 taken 44826 times.
✓ Branch 1 taken 685 times.
45511 if((clk4&63)==0)
13265 {
13266
2/2
✓ Branch 0 taken 358 times.
✓ Branch 1 taken 327 times.
685 if(clk4&64)
13267 358 dir^=1;
13268 else
13269 327 dir=zc_oldrand()%3+1;
13270 685 }
13271
13272
2/2
✓ Branch 0 taken 44776 times.
✓ Branch 1 taken 735 times.
45511 if((clk&63)==3)
13273 {
13274
2/2
✓ Branch 0 taken 548 times.
✓ Branch 1 taken 187 times.
735 switch(dmisc1)
13275 {
13276 case 1:
13277 187 addEwpn(x,y+2,z,wpn,3,wdp,left,getUID(), 0, fakez);
13278 187 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13279 187 addEwpn(x,y+2,z,wpn,3,wdp,right,getUID(), 0, fakez);
13280 187 sfx(wpnsfx(wpn),pan(int32_t(x)));
13281 187 break;
13282
13283 default:
13284
3/4
✓ Branch 0 taken 548 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 463 times.
548 if(dmisc1 != 1 && dmisc1 != 2)
13285 {
13286 463 addEwpn(x,y+2,z,wpn,3,wdp,8,getUID(), 0, fakez);
13287 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13288 463 sfx(wpnsfx(wpn),pan(int32_t(x)));
13289 463 }
13290
13291 548 break;
13292 }
13293 735 }
13294
13295
6/6
✓ Branch 0 taken 5356 times.
✓ Branch 1 taken 40155 times.
✓ Branch 2 taken 5084 times.
✓ Branch 3 taken 272 times.
✓ Branch 4 taken 3692 times.
✓ Branch 5 taken 1392 times.
45511 if((dmisc1 == 2)&& clk3>=16 && clk3<116)
13296 {
13297
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 1209 times.
1392 if(!(clk3%8))
13298 {
13299 183 FireBreath(true);
13300 183 }
13301 1392 }
13302
13303
2/2
✓ Branch 0 taken 22736 times.
✓ Branch 1 taken 22775 times.
45511 if(clk4&1)
13304 22775 move((zfix)1);
13305
13306
2/2
✓ Branch 0 taken 45411 times.
✓ Branch 1 taken 100 times.
45511 if(++clk3>=400)
13307 100 clk3=0;
13308
13309 45511 return enemy::animate(index);
13310 46569 }
13311
13312 46567 void eGohma::draw(BITMAP *dest)
13313 {
13314 46567 tile=o_tile;
13315
13316
4/4
✓ Branch 0 taken 46279 times.
✓ Branch 1 taken 288 times.
✓ Branch 2 taken 770 times.
✓ Branch 3 taken 45509 times.
46567 if(clk<0 || dying)
13317 {
13318 1058 enemy::drawzcboss(dest);
13319 1058 return;
13320 }
13321
13322
2/2
✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 12333 times.
45509 if(get_qr(qr_NEWENEMYTILES))
13323 {
13324 ///if ( do_animation )
13325 //Yuck. Gohma can just not have this capability right now.
13326 // left side
13327 33176 xofs=-16;
13328 33176 flip=0;
13329 // if(clk&16) tile=180;
13330 // else { tile=182; flip=1; }
13331 33176 tile+=(3*((clk&48)>>4));
13332 33176 enemy::drawzcboss(dest);
13333
13334 // right side
13335 33176 xofs=16;
13336 // tile=(180+182)-tile;
13337 33176 tile=o_tile;
13338 33176 tile+=(3*((clk&48)>>4))+2;
13339 33176 enemy::drawzcboss(dest);
13340
13341 // body
13342 33176 xofs=0; //Gohma may need more adjustments for SIZEflags. -Z 14 Aug 2020
13343 33176 tile=o_tile;
13344
13345 // tile+=(3*((clk&24)>>3))+2;
13346
2/2
✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 31417 times.
33176 if(clk3<16)
13347 1759 tile+=7;
13348
2/2
✓ Branch 0 taken 9419 times.
✓ Branch 1 taken 21998 times.
31417 else if(clk3<116)
13349 9419 tile+=10;
13350
2/2
✓ Branch 0 taken 1315 times.
✓ Branch 1 taken 20683 times.
21998 else if(clk3<132)
13351 1315 tile+=7;
13352 else
13353 20683 tile+=((clk3-132)&24)?4:1;
13354
13355 33176 enemy::drawzcboss(dest);
13356
13357 33176 }
13358 else
13359 {
13360 // left side
13361 12333 xofs=-16;
13362 12333 flip=0;
13363
13364
2/2
✓ Branch 0 taken 6107 times.
✓ Branch 1 taken 6226 times.
12333 if(!(clk&16))
13365 {
13366 6226 tile+=2;
13367 6226 flip=1;
13368 6226 }
13369
13370 12333 enemy::draw(dest);
13371
13372 // right side
13373 12333 tile=o_tile;
13374 12333 xofs=16;
13375
13376
2/2
✓ Branch 0 taken 6226 times.
✓ Branch 1 taken 6107 times.
12333 if((clk&16)) tile+=2;
13377
13378 // tile=(180+182)-tile;
13379 12333 enemy::draw(dest);
13380
13381 // body
13382 12333 tile=o_tile;
13383 12333 xofs=0;
13384
13385
2/2
✓ Branch 0 taken 720 times.
✓ Branch 1 taken 11613 times.
12333 if(clk3<16)
13386 720 tile+=4;
13387
2/2
✓ Branch 0 taken 3884 times.
✓ Branch 1 taken 7729 times.
11613 else if(clk3<116)
13388 3884 tile+=5;
13389
2/2
✓ Branch 0 taken 473 times.
✓ Branch 1 taken 7256 times.
7729 else if(clk3<132)
13390 473 tile+=4;
13391 7256 else tile+=((clk3-132)&8)?3:1;
13392
13393 12333 enemy::draw(dest);
13394
13395 }
13396 46567 }
13397
13398 230 int32_t eGohma::takehit(weapon *w, weapon* realweap)
13399 {
13400 230 int32_t wpnId = w->id;
13401 230 int32_t power = w->power;
13402 230 int32_t wpnx = w->x;
13403 230 int32_t wpnDir = w->dir;
13404 230 int32_t def = defenditemclassNew(wpnId, &power, w, realweap);
13405
13406
2/2
✓ Branch 0 taken 122 times.
✓ Branch 1 taken 108 times.
230 if(def < 0)
13407 {
13408
7/10
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 27 times.
✓ Branch 6 taken 80 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 67 times.
✓ Branch 9 taken 13 times.
108 if(!((wpnDir==up || wpnDir==l_up || wpnDir==r_up) && abs(int32_t(x)-wpnx)<=8 && clk3>=16 && clk3<116))
13409 {
13410 41 sfx(WAV_CHINK,pan(int32_t(x)));
13411 41 return 1;
13412 }
13413 67 }
13414
13415 189 return enemy::takehit(w, realweap);
13416 230 }
13417
13418 198 eLilDig::eLilDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13419 198 {
13420 198 count_enemy=(id==(id&0xFFF));
13421 //nets+4360+(((id&0xFF)-eDIGPUP2)*40);
13422 198 SIZEflags = d->SIZEflags;
13423
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13424 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13425 // al_trace("Enemy txsz:%i\n", txsz);
13426
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13427
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13428
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13429
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13430
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13431
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13432 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13433
1/4
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13434
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13435 {
13436 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13437 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13438 }
13439
13440
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
198 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13441 198 }
13442
13443 75067 bool eLilDig::animate(int32_t index)
13444 {
13445
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 75067 times.
75067 if(switch_hooked) return enemy::animate(index);
13446
2/2
✓ Branch 0 taken 3006 times.
✓ Branch 1 taken 72061 times.
75067 if(dying)
13447 3006 return Dead(index);
13448
13449
2/2
✓ Branch 0 taken 4113 times.
✓ Branch 1 taken 67948 times.
72061 if(clk==0)
13450 {
13451 4113 removearmos(x,y,ffcactivated);
13452 4113 }
13453
13454
2/2
✓ Branch 0 taken 48439 times.
✓ Branch 1 taken 23622 times.
72061 if(misc<=128)
13455 {
13456
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 22911 times.
23622 if(!(++misc&31))
13457 711 step+=0.25;
13458 23622 }
13459
13460 72061 variable_walk_8(rate,homing,hrate,spw_floater);
13461 72061 return enemy::animate(index);
13462 75067 }
13463
13464 74914 void eLilDig::draw(BITMAP *dest)
13465 {
13466 74914 tile = o_tile;
13467 // tile = 160;
13468 74914 int32_t fdiv = frate/4;
13469
1/2
✓ Branch 0 taken 74914 times.
✗ Branch 1 not taken.
74914 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13470
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13471 74914 efrate:((clk>=(frate>>1))?1:0);
13472
13473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74914 times.
74914 if ( do_animation )
13474 {
13475
2/2
✓ Branch 0 taken 46311 times.
✓ Branch 1 taken 28603 times.
74914 if(get_qr(qr_NEWENEMYTILES))
13476 {
13477
9/9
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 5465 times.
✓ Branch 2 taken 5245 times.
✓ Branch 3 taken 5717 times.
✓ Branch 4 taken 5242 times.
✓ Branch 5 taken 4505 times.
✓ Branch 6 taken 3937 times.
✓ Branch 7 taken 5312 times.
✓ Branch 8 taken 5035 times.
46311 switch(dir-8) //directions get screwed up after 8. *shrug*
13478 {
13479 case up: //u
13480 5853 flip=0;
13481 5853 break;
13482
13483 case l_up: //d
13484 5465 flip=0;
13485 5465 tile+=4;
13486 5465 break;
13487
13488 case l_down: //l
13489 5245 flip=0;
13490 5245 tile+=8;
13491 5245 break;
13492
13493 case left: //r
13494 5717 flip=0;
13495 5717 tile+=12;
13496 5717 break;
13497
13498 case r_down: //ul
13499 5242 flip=0;
13500 5242 tile+=20;
13501 5242 break;
13502
13503 case down: //ur
13504 4505 flip=0;
13505 4505 tile+=24;
13506 4505 break;
13507
13508 case r_up: //dl
13509 3937 flip=0;
13510 3937 tile+=28;
13511 3937 break;
13512
13513 case right: //dr
13514 5035 flip=0;
13515 5035 tile+=32;
13516 5035 break;
13517 }
13518
13519 46311 tile+=f2;
13520 46311 }
13521 else
13522 {
13523 28603 tile+=(clk>=6)?1:0;
13524 }
13525 74914 }
13526
13527 74914 enemy::draw(dest);
13528 74914 }
13529
13530 52 eBigDig::eBigDig(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13531 52 {
13532 52 superman=1;
13533
13534 52 SIZEflags = d->SIZEflags;
13535
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
13536 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
13537 // al_trace("Enemy txsz:%i\n", txsz);
13538
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
13539
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
13540 52 else hit_width=32;
13541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
13542 52 else hit_height=32;
13543
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
13544 52 else hzsz=16; // hard to jump.
13545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
13546 52 else hxofs=-8;
13547
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
13548 52 else hyofs=-8;
13549 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
13550
1/4
✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
13551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
13552 {
13553 yofs = d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
13554 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
13555 }
13556
13557
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
52 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
13558
13559
13560 52 }
13561
13562 22457 bool eBigDig::animate(int32_t index)
13563 {
13564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(switch_hooked) return enemy::animate(index);
13565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22457 times.
22457 if(dying)
13566 return Dead(index);
13567
13568
2/2
✓ Branch 0 taken 19263 times.
✓ Branch 1 taken 3194 times.
22457 if(clk==0)
13569 {
13570 3194 removearmos(x,y,ffcactivated);
13571 3194 }
13572
13573
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 22369 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 44 times.
22457 switch(misc)
13574 {
13575 case 0:
13576 22369 variable_walk_8(rate,homing,hrate,spw_floater,-8,-16,23,23);
13577 22369 break;
13578
13579 case 1:
13580 44 ++misc;
13581 44 break;
13582
13583 case 2:
13584
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 44 times.
149 for(int32_t i=0; i<dmisc5; i++)
13585 {
13586 105 addenemy(x,y,dmisc1+0x1000,-15);
13587 105 }
13588
13589
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc6; i++)
13590 {
13591 16 addenemy(x,y,dmisc2+0x1000,-15);
13592 16 }
13593
13594
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc7; i++)
13595 {
13596 16 addenemy(x,y,dmisc3+0x1000,-15);
13597 16 }
13598
13599
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 for(int32_t i=0; i<dmisc8; i++)
13600 {
13601 16 addenemy(x,y,dmisc4+0x1000,-15);
13602 16 }
13603
13604
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1 times.
44 if(itemguy) // Hand down the carried item
13605 {
13606 1 guycarryingitem = guys.Count()-1;
13607 1 ((enemy*)guys.spr(guycarryingitem))->itemguy = true;
13608 1 itemguy = false;
13609 1 }
13610
13611 44 stop_bgsfx(index);
13612
13613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(deadsfx > 0) sfx(deadsfx,pan(int32_t(x)));
13614
13615 44 return true;
13616 }
13617
13618 22413 return enemy::animate(index);
13619 22457 }
13620
13621 22452 void eBigDig::draw(BITMAP *dest)
13622 {
13623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if(anim!=aDIG)
13624 {
13625 update_enemy_frame();
13626 xofs-=8;
13627 yofs-=8;
13628 drawblock(dest,15);
13629 xofs+=8;
13630 yofs+=8;
13631 return;
13632 }
13633
13634 22452 tile = o_tile;
13635 22452 int32_t fdiv = frate/4;
13636
1/2
✓ Branch 0 taken 22452 times.
✗ Branch 1 not taken.
22452 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
13637
13638
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 int32_t f2=get_qr(qr_NEWENEMYTILES)?
13639 22452 efrate:((clk>=(frate>>1))?1:0);
13640
13641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22452 times.
22452 if ( do_animation )
13642 {
13643
2/2
✓ Branch 0 taken 10238 times.
✓ Branch 1 taken 12214 times.
22452 if(get_qr(qr_NEWENEMYTILES))
13644 {
13645
9/9
✓ Branch 0 taken 1115 times.
✓ Branch 1 taken 1221 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 1195 times.
✓ Branch 4 taken 1233 times.
✓ Branch 5 taken 1223 times.
✓ Branch 6 taken 993 times.
✓ Branch 7 taken 1450 times.
✓ Branch 8 taken 464 times.
10238 switch(dir-8) //directions get screwed up after 8. *shrug*
13646 {
13647 case up: //u
13648 1115 flip=0;
13649 1115 break;
13650
13651 case l_up: //d
13652 1221 flip=0;
13653 1221 tile+=8;
13654 1221 break;
13655
13656 case l_down: //l
13657 1344 flip=0;
13658 1344 tile+=40;
13659 1344 break;
13660
13661 case left: //r
13662 1195 flip=0;
13663 1195 tile+=48;
13664 1195 break;
13665
13666 case r_down: //ul
13667 1233 flip=0;
13668 1233 tile+=80;
13669 1233 break;
13670
13671 case down: //ur
13672 1223 flip=0;
13673 1223 tile+=88;
13674
13675 1223 break;
13676
13677 case r_up: //dl
13678 993 flip=0;
13679 993 tile+=120;
13680 993 break;
13681
13682 case right: //dr
13683 1450 flip=0;
13684 1450 tile+=128;
13685 1450 break;
13686 }
13687
13688 10238 tile+=(f2*2);
13689 10238 }
13690 else
13691 {
13692 12214 tile+=(f2)?0:2;
13693 12214 flip=(clk&1)?1:0;
13694 }
13695 22452 }
13696
13697 22452 xofs-=8;
13698 22452 yofs-=8;
13699 22452 drawblock(dest,15);
13700 22452 xofs+=8;
13701 22452 yofs+=8;
13702 22452 }
13703
13704 740 int32_t eBigDig::takehit(weapon *w, weapon* realweap)
13705 {
13706 740 int32_t wpnId = w->id;
13707
13708
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 696 times.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
740 if(wpnId==wWhistle && misc==0)
13709 44 misc=1;
13710
13711 740 return 0;
13712 }
13713
13714 /*
13715 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
13716 {
13717 hxofs=hyofs=8;
13718 hzsz=16; //can't be jumped.
13719 clk2=70;
13720 misc=-1;
13721 mainguy=!getmapflag();
13722 }
13723
13724 bool eGanon::animate(int32_t index)
13725 {
13726 if(switch_hooked) return enemy::animate(index);
13727 if(dying)
13728
13729 return Dead(index);
13730
13731 if(clk==0)
13732 {
13733 removearmos(x,y,ffcactivated);
13734 }
13735
13736 switch(misc)
13737 {
13738 case -1:
13739 misc=0;
13740
13741 case 0:
13742 if(++clk2>72 && !(zc_oldrand()&3))
13743 {
13744 addEwpn(x,y,z,wpn,3,wdp,dir,getUID());
13745 sfx(wpnsfx(wpn),pan(int32_t(x)));
13746 clk2=0;
13747 }
13748
13749 Stunclk=0;
13750 constant_walk(rate,homing,spw_none);
13751 break;
13752
13753 case 1:
13754 case 2:
13755 if(--Stunclk<=0)
13756 {
13757 int32_t r=zc_oldrand();
13758
13759 if(r&1)
13760 {
13761 y=96;
13762
13763 if(r&2)
13764 x=160;
13765 else
13766 x=48;
13767
13768 if(tooclose(x,y,48))
13769 x=208-x;
13770 }
13771
13772 //if ( editorflags & ENEMY_FLAG15 && current_item_id(itype_amulet,false) >= 2 ) //visible to Amulet 2
13773 //{
13774 // loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13775 // }
13776 // else
13777 // {
13778 loadpalset(csBOSS,pSprite(d->bosspal));
13779 // }
13780 misc=0;
13781 }
13782
13783 break;
13784
13785 case 3:
13786 {
13787 if(hclk>0)
13788 break;
13789
13790 misc=4;
13791 clk=0;
13792 hxofs=1000;
13793 loadpalset(9,pSprite(spPILE));
13794 music_stop();
13795 stop_sfx(WAV_ROAR);
13796
13797 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
13798
13799 sfx(WAV_GANON);
13800 //Ganon's dustpile; fall in sideview. -Z
13801 item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
13802 dustpile->linked_parent = eeGANON;
13803 setmapflag();
13804 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
13805 break;
13806 }
13807
13808 case 4:
13809 if(clk>=80)
13810 {
13811 misc=5;
13812
13813 if(getmapflag())
13814 {
13815 game->lvlitems[dlevel]|=liBOSS;
13816 //play_DmapMusic();
13817 playLevelMusic();
13818 return true;
13819 }
13820
13821 sfx(WAV_CLEARED);
13822 items.add(new item(x+8,y+8,(zfix)0,iBigTri,ipBIGTRI,0));
13823 setmapflag();
13824 }
13825
13826 break;
13827 }
13828
13829 //if ( editorflags & ENEMY_FLAG15 ) //visible to Amulet 2
13830 //{
13831 //if ( current_item_id(itype_amulet,false) >= 2 )
13832 //{
13833 /// loadpalset(9,pSprite(spBROWN)); //make Ganon visible?
13834 //}
13835 //}
13836
13837
13838 return enemy::animate(index);
13839 }
13840
13841
13842 int32_t eGanon::takehit(weapon *w, weapon* realweap)
13843 {
13844 //these are here to bypass compiler warnings about unused arguments
13845 int32_t wpnId = w->id;
13846 int32_t power = w->power;
13847 int32_t enemyHitWeapon = w->parentitem;
13848
13849 switch(misc)
13850 {
13851 case 0:
13852 {
13853 //if we're not using the editor defences, and Ganon isn't hit by a sword, return.
13854 if(wpnId!=wSword && !(editorflags & ENEMY_FLAG14))
13855 return 0;
13856
13857 //if we are not using the new defences, just reduce his HP
13858 if (!(editorflags & ENEMY_FLAG14))
13859 {
13860 hp-=power;
13861 if(hp>0)
13862 {
13863 misc=1;
13864 Stunclk=64;
13865 }
13866 else
13867 {
13868 loadpalset(csBOSS,pSprite(spBROWN));
13869 misc=2;
13870 Stunclk=284;
13871 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13872 }
13873
13874 sfx(WAV_EHIT,pan(int32_t(x)));
13875
13876 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13877
13878 return 1;
13879 }
13880 //otherwise, resolve his defence.
13881 else
13882 {
13883 int32_t def = enemy::takehit(w,realweap); //This works, but it instantly kills him if it does enough damage.
13884 if(hp>0)
13885 {
13886 misc=1;
13887 Stunclk=64;
13888 }
13889 else
13890 {
13891 loadpalset(csBOSS,pSprite(spBROWN));
13892 misc=2;
13893 Stunclk=284;
13894 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
13895 }
13896
13897 sfx(WAV_EHIT,pan(int32_t(x)));
13898
13899 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
13900
13901
13902 return 1;
13903 }
13904 }
13905 case 2:
13906 {
13907 if
13908 (
13909 ( dmisc14 > 0 && !enemyHitWeapon == dmisc14 ) //special weapon needed to kill ganon specified in editor
13910 || //or nothing specified, use silver arrows+
13911 ( dmisc14 <= 0 && (wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4))
13912 )
13913 return 0;
13914 {
13915 misc=3;
13916 hclk=81;
13917 loadpalset(9,pSprite(spBROWN));
13918 return 1;
13919 }
13920
13921 }
13922 }
13923
13924 return 0;
13925 }
13926
13927 void eGanon::draw(BITMAP *dest)
13928 {
13929 switch(misc)
13930 {
13931 case 0:
13932 if((clk&3)==3)
13933 tile=(zc_oldrand()%5)*2+o_tile;
13934
13935 if(db!=999)
13936 break;
13937
13938 case 2:
13939 if(Stunclk<64 && (Stunclk&1) )
13940 {
13941 if
13942 (
13943 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13944 ||
13945 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13946 )
13947 {
13948 goto ganon_draw; //draw his weapons if we can see him
13949 }
13950 break;
13951 }
13952
13953 case -1:
13954 tile=o_tile;
13955
13956 //fall through
13957 case 1:
13958 case 3:
13959 ganon_draw:
13960 drawblock(dest,15);
13961 break;
13962
13963 case 4:
13964 draw_guts(dest);
13965 draw_flash(dest);
13966 break;
13967 }
13968
13969 if ( editorflags & ENEMY_FLAG1 ) //visible to Amulet 2
13970 {
13971 if
13972 (
13973 ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 && (editorflags & ENEMY_FLAG15) )
13974 ||
13975 ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) && (editorflags & ENEMY_FLAG15) )
13976 )
13977 {
13978 draw_guts(dest); //makes his shots visible, but not him
13979 draw_flash(dest);
13980 }
13981 }
13982 }
13983
13984 void eGanon::draw_guts(BITMAP *dest)
13985 {
13986 int32_t c = zc_min(clk>>3,8);
13987 tile = clk<24 ? 74 : 75;
13988 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
13989 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
13990 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
13991 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
13992 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
13993 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
13994 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
13995 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
13996 }
13997
13998 void eGanon::draw_flash(BITMAP *dest)
13999 {
14000
14001 int32_t c = clk-(clk>>2);
14002 cs = (frame&3)+6;
14003 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14004 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14005 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14006 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14007 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14008 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14009 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14010 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14011 }
14012 */
14013
14014 10 eGanon::eGanon(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14015 10 {
14016 10 hxofs=hyofs=8;
14017
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if (editorflags & ENEMY_FLAG3)
14018 {
14019 hxofs = 4;
14020 hyofs = 4;
14021 hit_width = 24;
14022 hit_height = 24;
14023 SIZEflags|=guyflagOVERRIDE_HIT_WIDTH;
14024 SIZEflags|=guyflagOVERRIDE_HIT_HEIGHT;
14025 }
14026 10 hzsz=16; //can't be jumped.
14027 10 clk2=70;
14028 10 misc=-1;
14029
4/8
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10 times.
✗ Branch 7 not taken.
20 mainguy=(!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr->flags9&fBELOWRETURN));
14030 10 }
14031
14032 15877 bool eGanon::animate(int32_t index) //DO NOT ADD a check for do_animation to this version of GANON!! -Z
14033 {
14034
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15877 times.
15877 if(dying)
14035
14036 return Dead(index);
14037
14038
2/2
✓ Branch 0 taken 15814 times.
✓ Branch 1 taken 63 times.
15877 if(clk==0)
14039 {
14040 63 removearmos(x,y,ffcactivated);
14041 63 }
14042
14043
6/7
✓ Branch 0 taken 2935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11467 times.
✓ Branch 3 taken 10 times.
✓ Branch 4 taken 738 times.
✓ Branch 5 taken 720 times.
✓ Branch 6 taken 7 times.
15877 switch(misc)
14044 {
14045 case -1:
14046 10 misc=0;
14047 [[fallthrough]];
14048 case 0:
14049
4/4
✓ Branch 0 taken 627 times.
✓ Branch 1 taken 10850 times.
✓ Branch 2 taken 471 times.
✓ Branch 3 taken 156 times.
11477 if(++clk2>72 && !(zc_oldrand()&3))
14050 {
14051 156 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
14052 156 sfx(wpnsfx(wpn),pan(int32_t(x)));
14053 156 clk2=0;
14054 156 }
14055
14056 11477 Stunclk=0;
14057 11477 constant_walk(rate,homing,spw_none);
14058 11477 break;
14059
14060 case 1:
14061 case 2:
14062
2/2
✓ Branch 0 taken 2901 times.
✓ Branch 1 taken 34 times.
2935 if(--Stunclk<=0)
14063 {
14064 34 int32_t r=zc_oldrand();
14065
14066
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 14 times.
34 if(r&1)
14067 {
14068 14 y=96;
14069
14070
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if(r&2)
14071 6 x=160;
14072 else
14073 8 x=48;
14074
14075
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
14 if(tooclose(x,y,48))
14076 6 x=208-x;
14077 14 }
14078
14079 34 loadpalset(csBOSS,pSprite(d->bosspal));
14080 34 misc=0;
14081 34 }
14082
14083 2935 break;
14084
14085 case 3:
14086 {
14087
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 9 times.
738 if(hclk>0)
14088 729 break;
14089
14090 9 misc=4;
14091 9 clk=0;
14092 9 hxofs=1000;
14093 9 loadpalset(9,pSprite(spPILE));
14094 9 music_stop();
14095 9 stop_sfx(WAV_ROAR);
14096
14097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(deadsfx>0) sfx(deadsfx,pan(int32_t(x)));
14098
14099 9 sfx(WAV_GANON);
14100 //Ganon's dustpile; fall in sideview. -Z
14101 //item *dustpile = new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0);
14102 //dustpile->miscellaneous[31] = eeGANON;
14103
6/12
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 9 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 9 times.
✗ Branch 11 not taken.
9 items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14104 9 item *dustpile = NULL;
14105 //dustpile = (item *)items.spr(items.Count() - 1)->getUID();
14106 9 dustpile = (item *)items.spr(items.Count() - 1);
14107 9 dustpile->linked_parent = eeGANON; //was miscellaneous[31]
14108 //setmapflag(); //Could be why the Triforce doesn't drop. Disabling this now. -Z ( 6th March, 2019 )
14109 //items.add(new item(x+8,y+8,(zfix)0,iPile,ipDUMMY,0));
14110 9 break;
14111 }
14112
14113 case 4:
14114
2/2
✓ Branch 0 taken 711 times.
✓ Branch 1 taken 9 times.
720 if(clk>=80)
14115 {
14116 9 misc=5;
14117
14118 //game->lvlitems[dlevel]|=liBOSS;
14119
14120 9 sfx(WAV_CLEARED);
14121 //Add the big TF over the ashes!
14122
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 9 times.
27 for(word q = 0; q < items.Count(); q++)
14123 {
14124 18 item *ashes = (item*)items.spr(q);
14125
3/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 9 times.
18 if ( ashes->linked_parent == eeGANON && (ashes->pickup&ipDUMMY))
14126 {
14127 //Z_scripterrlog("Found correct dustpile!\n");
14128
4/8
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 9 times.
✗ Branch 7 not taken.
9 items.add(new item(ashes->x,ashes->y,(zfix)0,iBigTri,ipBIGTRI,0));
14129 9 item *bigtriforce = NULL;
14130 9 bigtriforce = (item *)items.spr(items.Count() - 1);
14131 9 bigtriforce->linked_parent = eeGANON;
14132 9 }
14133 18 }
14134 //setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14135 //game->lvlitems[dlevel]|=liBOSS; // if we had more rule bits, we could mark him dead so that he does not respawn. -Z
14136 9 }
14137
14138 720 break;
14139 7 case 5: return true;
14140 }
14141
14142 15870 return enemy::animate(index);
14143 15877 }
14144
14145
14146 803 int32_t eGanon::takehit(weapon *w, weapon* realweap)
14147 {
14148 //these are here to bypass compiler warnings about unused arguments
14149 803 int32_t wpnId = w->id;
14150 803 int32_t power = w->power;
14151 803 int32_t enemyHitWeapon = w->parentitem;
14152
14153
3/3
✓ Branch 0 taken 604 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 125 times.
803 switch(misc)
14154 {
14155 case 0:
14156
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 43 times.
74 if(wpnId!=wSword)
14157 31 return 0;
14158
14159 43 hp-=power;
14160
14161
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 9 times.
43 if(hp>0)
14162 {
14163 34 misc=1;
14164 34 Stunclk=64;
14165 34 }
14166 else
14167 {
14168 9 loadpalset(csBOSS,pSprite(spBROWN));
14169 9 misc=2;
14170 9 Stunclk=284;
14171 9 hp=guysbuf[id&0xFFF].hp; //16*game->get_hero_dmgmult();
14172 }
14173
14174 43 sfx(WAV_EHIT,pan(int32_t(x)));
14175
14176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(hitsfx>0) sfx(hitsfx,pan(int32_t(x)));
14177
14178 43 return 1;
14179
14180 case 2:
14181
4/6
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
125 if(wpnId!=wArrow || (enemyHitWeapon>-1 ? itemsbuf[enemyHitWeapon].power : current_item_power(itype_arrow))<4)
14182 116 return 0;
14183
14184 9 misc=3;
14185 9 hclk=81;
14186 9 loadpalset(9,pSprite(spBROWN));
14187 9 return 1;
14188 }
14189
14190 604 return 0;
14191 803 }
14192
14193 17817 void eGanon::draw(BITMAP *dest)
14194 {
14195
6/6
✓ Branch 0 taken 2914 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 759 times.
✓ Branch 3 taken 1950 times.
✓ Branch 4 taken 11467 times.
✓ Branch 5 taken 720 times.
17817 switch(misc)
14196 {
14197 case 0:
14198
2/2
✓ Branch 0 taken 8601 times.
✓ Branch 1 taken 2866 times.
11467 if((clk&3)==3)
14199 2866 tile=(zc_oldrand()%5)*2+o_tile;
14200
14201
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 if ( (editorflags & ENEMY_FLAG1) && current_item_power(itype_amulet) >= 2 ) //ganon is visible to level 2 amulet
14202 {
14203
14204 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14205 {
14206 int odraw = drawstyle;
14207 drawstyle = 2;
14208 drawblock(dest,15);
14209 drawstyle = odraw;
14210 }
14211 else
14212 {
14213 drawblock(dest,15);
14214 }
14215 break;
14216
14217 }
14218
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11467 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11467 else if ( (editorflags & ENEMY_FLAG2) && (game->item[dmisc13]) )
14219 {
14220 if ( editorflags & ENEMY_FLAG16 ) //draw cloaked
14221 {
14222 int odraw = drawstyle;
14223 drawstyle = 2;
14224 drawblock(dest,15);
14225 drawstyle = odraw;
14226 }
14227 else
14228 {
14229 drawblock(dest,15);
14230 }
14231 break;
14232 }
14233
1/2
✓ Branch 0 taken 11467 times.
✗ Branch 1 not taken.
11467 if(db!=999)
14234 11467 break;
14235 [[fallthrough]];
14236 case 2:
14237
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 759 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
759 if(Stunclk<64 && (Stunclk&1))
14238 break;
14239 [[fallthrough]];
14240 case -1:
14241 2709 tile=o_tile;
14242
14243 [[fallthrough]];
14244 case 1:
14245 case 3:
14246 5623 drawblock(dest,15);
14247 5623 break;
14248
14249 case 4:
14250 720 draw_guts(dest);
14251 720 draw_flash(dest);
14252 720 break;
14253 }
14254 17817 }
14255
14256 720 void eGanon::draw_guts(BITMAP *dest)
14257 {
14258
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 153 times.
720 int32_t c = zc_min(clk>>3,8);
14259 720 tile = clk<24 ? 74 : 75;
14260 720 overtile16(dest,tile,x+8,y+c+playing_field_offset,9,0);
14261 720 overtile16(dest,tile,x+8,y+16-c+playing_field_offset,9,0);
14262 720 overtile16(dest,tile,x+c,y+8+playing_field_offset,9,0);
14263 720 overtile16(dest,tile,x+16-c,y+8+playing_field_offset,9,0);
14264 720 overtile16(dest,tile,x+c,y+c+playing_field_offset,9,0);
14265 720 overtile16(dest,tile,x+16-c,y+c+playing_field_offset,9,0);
14266 720 overtile16(dest,tile,x+c,y+16-c+playing_field_offset,9,0);
14267 720 overtile16(dest,tile,x+16-c,y+16-c+playing_field_offset,9,0);
14268 720 }
14269
14270 720 void eGanon::draw_flash(BITMAP *dest)
14271 {
14272
14273 720 int32_t c = clk-(clk>>2);
14274 720 cs = (frame&3)+6;
14275 720 overtile16(dest,194,x+8,y+8-clk+playing_field_offset,cs,0);
14276 720 overtile16(dest,194,x+8,y+8+clk+playing_field_offset,cs,2);
14277 720 overtile16(dest,195,x+8-clk,y+8+playing_field_offset,cs,0);
14278 720 overtile16(dest,195,x+8+clk,y+8+playing_field_offset,cs,1);
14279 720 overtile16(dest,196,x+8-c,y+8-c+playing_field_offset,cs,0);
14280 720 overtile16(dest,196,x+8+c,y+8-c+playing_field_offset,cs,1);
14281 720 overtile16(dest,196,x+8-c,y+8+c+playing_field_offset,cs,2);
14282 720 overtile16(dest,196,x+8+c,y+8+c+playing_field_offset,cs,3);
14283 720 }
14284
14285 8 void getBigTri(int32_t id2)
14286 {
14287 /*
14288 *************************
14289 * BIG TRIFORCE SEQUENCE *
14290 *************************
14291 0 BIGTRI out, WHITE flash in
14292 4 WHITE flash out, PILE cset white
14293 8 WHITE in
14294 ...
14295 188 WHITE out
14296 191 PILE cset red
14297 200 top SHUTTER opens
14298 209 bottom SHUTTER opens
14299 */
14300 8 sfx(itemsbuf[id2].playsound);
14301 8 guys.clear();
14302
14303
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(itemsbuf[id2].flags & ITEM_GAMEDATA)
14304 {
14305 game->lvlitems[dlevel]|=liTRIFORCE;
14306 }
14307
14308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
14309
14310 8 draw_screen(tmpscr);
14311
14312
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 1536 times.
1544 for(int32_t f=0; f<24*8 && !Quit; f++)
14313 {
14314
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==4)
14315 {
14316
2/2
✓ Branch 0 taken 120 times.
✓ Branch 1 taken 8 times.
128 for(int32_t i=1; i<16; i++)
14317 {
14318 120 RAMpal[CSET(9)+i]=_RGB(63,63,63);
14319 120 }
14320 8 }
14321
14322
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==0)
14323 {
14324
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 192 times.
768 for(int32_t cs=2; cs<5; cs++)
14325 {
14326
2/2
✓ Branch 0 taken 8640 times.
✓ Branch 1 taken 576 times.
9216 for(int32_t i=1; i<16; i++)
14327 {
14328 8640 RAMpal[CSET(cs)+i]=_RGB(63,63,63);
14329 8640 }
14330 576 }
14331
14332 192 refreshpal=true;
14333 192 }
14334
14335
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 192 times.
1536 if((f&7)==4)
14336 {
14337
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(currscr<128) loadlvlpal(DMaps[currdmap].color);
14338 else loadlvlpal(0xB);
14339 192 }
14340
14341
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 8 times.
1536 if(f==191)
14342 {
14343 8 loadpalset(9,pSprite(spPILE));
14344 8 }
14345
14346 1536 advanceframe(true);
14347 1536 }
14348
14349 //play_DmapMusic();
14350 8 playLevelMusic();
14351
14352
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(itemsbuf[id2].flags & ITEM_FLAG1 && currscr < 128)
14353 {
14354 Hero.dowarp(1,0); //side warp
14355 }
14356 8 }
14357
14358 /**********************************/
14359 /*** Multiple-Segment Enemies ***/
14360 /**********************************/
14361
14362
14363 //! No. I am not adding SIZEflags to Moldorm and Lanmola. -Z 12 Aug 2020
14364 94 eMoldorm::eMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14365 94 {
14366
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if( !(editorflags & ENEMY_FLAG5) )
14367 {
14368
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x=128;
14369
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y=48;
14370 94 }
14371 //else { x = X; y = Y; }
14372
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 dir=(zc_oldrand()&7)+8;
14373 94 superman=1;
14374 94 fading=fade_invisible;
14375 94 hxofs=1000;
14376 94 segcnt=clk;
14377 94 segid=Id|0x1000;
14378 94 clk=0;
14379
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 id=guys.Count();
14380
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 94 times.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14381 94 tile=o_tile;
14382 94 hitdir = -1;
14383 94 stickclk = 0;
14384
14385 /*
14386 if (get_qr(qr_NEWENEMYTILES))
14387 {
14388 tile=nets+1220;
14389 }
14390 else
14391 {
14392 tile=57;
14393 }
14394 */
14395 94 }
14396
14397 86130 bool eMoldorm::animate(int32_t index)
14398 {
14399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(switch_hooked) return enemy::animate(index);
14400 86130 int32_t max_y = isdungeon() ? 100 : 100+28; //warning: Ugly hack. -Z
14401
2/2
✓ Branch 0 taken 66843 times.
✓ Branch 1 taken 19287 times.
86130 if ( y > (max_y) )
14402 {
14403 19287 ++stickclk; //Keep Moldorm from pacinn the bottom row or leaving the screen via the bottom edge. -Z 8th Sept, 2019
14404 //Z_scripterrlog("Stickclk is %d\n", stickclk);
14405 19287 }
14406
2/2
✓ Branch 0 taken 85736 times.
✓ Branch 1 taken 394 times.
86130 if ( stickclk > 45 )
14407 {
14408 394 stickclk = 0;
14409 394 newdir_8_old(rate,homing,spw_floater); //chage dir to keep from getting stuck.
14410 394 }
14411
14412
14413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86130 times.
86130 if(clk==0)
14414 {
14415 86130 removearmos(x,y,ffcactivated);
14416 86130 }
14417
14418
2/2
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 84876 times.
86130 if(clk2)
14419 {
14420
2/2
✓ Branch 0 taken 1188 times.
✓ Branch 1 taken 66 times.
1254 if(--clk2 == 0)
14421 {
14422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
66 if(flags&guy_neverret)
14423 66 never_return(index);
14424
14425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 66 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
66 if(!dmisc2 || (editorflags & ENEMY_FLAG6))
14426 66 leave_item();
14427
14428 66 stop_bgsfx(index);
14429 66 return true;
14430 }
14431 1188 }
14432 else
14433 {
14434
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(stunclk>0)
14435 stunclk=0;
14436 84876 constant_walk_8_old(rate,homing,spw_floater);
14437
14438
14439 84876 misc=dir;
14440
14441 // If any higher-numbered segments were killed, segcnt can be too high,
14442 // leading to a crash
14443
1/2
✓ Branch 0 taken 84876 times.
✗ Branch 1 not taken.
84876 if(index+segcnt>=guys.Count())
14444 segcnt=guys.Count()-index-1;
14445
14446
2/2
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 453901 times.
538777 for(int32_t i=index+1; i<index+segcnt+1; i++)
14447 {
14448 453901 enemy* segment=((enemy*)guys.spr(i));
14449
14450 // More validation - if segcnt was wrong, this may not
14451 // actually be a Moldorm segment
14452
1/2
✓ Branch 0 taken 453901 times.
✗ Branch 1 not taken.
453901 if(segment->id!=segid)
14453 {
14454 segcnt=i-index-1;
14455 break;
14456 }
14457
14458
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1)
14459 {
14460 84966 x=segment->x;
14461 84966 y=segment->y;
14462 84966 }
14463
14464 453901 segment->o_tile=tile; //I refuse to fuck with adding scripttile to segmented enemies. -Z
14465 //Script your own blasted segmented bosses!! -Z
14466 453901 segment->parent_script_UID = this->script_UID;
14467
4/4
✓ Branch 0 taken 84876 times.
✓ Branch 1 taken 369025 times.
✓ Branch 2 taken 12139 times.
✓ Branch 3 taken 72737 times.
453901 if((i==index+segcnt)&&(i!=index+1)) //tail
14468 {
14469 72737 segment->dummy_int[1]=2;
14470 72737 }
14471 else
14472 {
14473 381164 segment->dummy_int[1]=1;
14474 }
14475
14476
2/2
✓ Branch 0 taken 368935 times.
✓ Branch 1 taken 84966 times.
453901 if(i==index+1) //head
14477 {
14478 84966 segment->dummy_int[1]=0;
14479 84966 }
14480
14481
2/2
✓ Branch 0 taken 453501 times.
✓ Branch 1 taken 400 times.
453901 if(segment->hp <= 0)
14482 {
14483 400 int32_t offset=1;
14484
14485
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 618 times.
1018 for(int32_t j=i; j<index+segcnt; j++)
14486 {
14487 // Triple-check
14488
1/2
✓ Branch 0 taken 618 times.
✗ Branch 1 not taken.
618 if(((enemy*)guys.spr(j+1))->id!=segid)
14489 {
14490 segcnt=j-index+1; // Add 1 because of --segcnt below
14491 break;
14492 }
14493 618 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14494 618 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14495 618 }
14496
14497 400 segment->hclk=33;
14498 400 --segcnt;
14499 400 --i; // Recheck the same index in case multiple segments died at once
14500 400 }
14501 453901 }
14502
14503
2/2
✓ Branch 0 taken 84810 times.
✓ Branch 1 taken 66 times.
84876 if(segcnt==0)
14504 {
14505 66 clk2=19;
14506
14507 66 x=guys.spr(index+1)->x;
14508 66 y=guys.spr(index+1)->y;
14509 66 }
14510 }
14511
14512 86064 return false;
14513 86130 }
14514
14515 530 esMoldorm::esMoldorm(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
14516 530 {
14517
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 if( !(editorflags & ENEMY_FLAG5) )
14518 {
14519
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 x=128;
14520
1/2
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
530 y=48;
14521 530 }
14522
14523
3/6
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 530 times.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
530 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
14524 530 hyofs=4;
14525 530 hit_width=hit_height=8;
14526 530 hxofs=1000;
14527 530 mainguy=count_enemy=false;
14528 530 parentclk = 0;
14529 530 bgsfx=-1;
14530 530 flags&=~guy_neverret;
14531 //deadsfx = WAV_EDEAD;
14532 530 isCore = false;
14533 530 }
14534
14535 460921 bool esMoldorm::animate(int32_t index)
14536 {
14537
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(switch_hooked) return enemy::animate(index);
14538 // Shouldn't be possible, but better to be sure
14539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460921 times.
460921 if(index==0)
14540 dying=true;
14541
14542
2/2
✓ Branch 0 taken 7020 times.
✓ Branch 1 taken 453901 times.
460921 if(dying)
14543 {
14544
1/2
✓ Branch 0 taken 7020 times.
✗ Branch 1 not taken.
7020 if(!dmisc2)
14545 7020 item_set=0;
14546
14547 7020 return Dead(index);
14548 }
14549
14550
2/2
✓ Branch 0 taken 22038 times.
✓ Branch 1 taken 431863 times.
453901 if(clk>=0)
14551 {
14552 431863 hxofs=4;
14553 431863 step=((enemy*)guys.spr(index-1))->step;
14554
14555
2/2
✓ Branch 0 taken 32657 times.
✓ Branch 1 taken 399206 times.
431863 if(parentclk == 0)
14556 {
14557 32657 misc=dir;
14558 32657 dir=((enemy*)guys.spr(index-1))->misc;
14559 //do alignment, as in parent's animation :-/ -DD
14560 32657 x.doFloor();
14561 32657 y.doFloor();
14562 32657 }
14563
14564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(step)
14565 431863 parentclk=(parentclk+1)%((int32_t)(8.0/step));
14566
14567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 431863 times.
431863 if(!watch)
14568 {
14569 431863 sprite::move(step);
14570 431863 }
14571 431863 }
14572
14573 453901 return enemy::animate(index);
14574 460921 }
14575
14576 1735 int32_t esMoldorm::takehit(weapon *w, weapon* realweap)
14577 {
14578
2/2
✓ Branch 0 taken 1588 times.
✓ Branch 1 taken 147 times.
1735 if(enemy::takehit(w,realweap))
14579 1588 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14580
14581 147 return 0;
14582 1735 }
14583
14584 462871 void esMoldorm::draw(BITMAP *dest)
14585 {
14586 462871 tile=o_tile;
14587 462871 int32_t fdiv = frate/4;
14588
1/2
✓ Branch 0 taken 462871 times.
✗ Branch 1 not taken.
462871 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14589
14590
2/2
✓ Branch 0 taken 385733 times.
✓ Branch 1 taken 77138 times.
462871 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14591 462871 efrate:((clk>=(frate>>1))?1:0);
14592
14593
2/2
✓ Branch 0 taken 77138 times.
✓ Branch 1 taken 385733 times.
462871 if(get_qr(qr_NEWENEMYTILES))
14594 {
14595 385733 tile+=dummy_int[1]*40;
14596
14597
2/2
✓ Branch 0 taken 17795 times.
✓ Branch 1 taken 367938 times.
385733 if(dir<8)
14598 {
14599 17795 flip=0;
14600
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 tile+=4*zc_max(dir, 0); // dir is -1 if trapped
14601
14602
1/2
✓ Branch 0 taken 17795 times.
✗ Branch 1 not taken.
17795 if(dir>3) // Skip to the next row for diagonals
14603 tile+=4;
14604 17795 }
14605 else
14606 {
14607
8/9
✓ Branch 0 taken 40703 times.
✓ Branch 1 taken 50522 times.
✓ Branch 2 taken 41128 times.
✓ Branch 3 taken 50152 times.
✓ Branch 4 taken 42370 times.
✓ Branch 5 taken 40742 times.
✓ Branch 6 taken 49191 times.
✓ Branch 7 taken 53130 times.
✗ Branch 8 not taken.
367938 switch(dir-8) //directions get screwed up after 8. *shrug*
14608 {
14609 case up: //u
14610 40703 flip=0;
14611 40703 break;
14612
14613 case l_up: //d
14614 50522 flip=0;
14615 50522 tile+=4;
14616 50522 break;
14617
14618 case l_down: //l
14619 41128 flip=0;
14620 41128 tile+=8;
14621 41128 break;
14622
14623 case left: //r
14624 50152 flip=0;
14625 50152 tile+=12;
14626 50152 break;
14627
14628 case r_down: //ul
14629 42370 flip=0;
14630 42370 tile+=20;
14631 42370 break;
14632
14633 case down: //ur
14634 40742 flip=0;
14635 40742 tile+=24;
14636 40742 break;
14637
14638 case r_up: //dl
14639 49191 flip=0;
14640 49191 tile+=28;
14641 49191 break;
14642
14643 case right: //dr
14644 53130 flip=0;
14645 53130 tile+=32;
14646 53130 break;
14647 }
14648 }
14649
14650 385733 tile+=f2;
14651 385733 }
14652
14653
2/2
✓ Branch 0 taken 22092 times.
✓ Branch 1 taken 440779 times.
462871 if(clk>=0)
14654 440779 enemy::draw(dest);
14655 462871 }
14656
14657 239 eLanmola::eLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14658 239 {
14659
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 if( !(editorflags & ENEMY_FLAG5) )
14660 {
14661
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 x=64;
14662
1/2
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
239 y=80;
14663 239 }
14664 //else { x = X; y = Y; }
14665 //zprint2("lanmola index is %d\n", index);
14666 //byte legaldirs = 0;
14667 239 int32_t incr = 16;
14668 //int32_t possiiblepos = 0;
14669 //int32_t positions[8] = {0};
14670
14671 //Don't spawn in pits.
14672
5/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 149 times.
✓ Branch 7 taken 90 times.
239 if ( m_walkflag_simple(x, y) )
14673 {
14674 //zprint2("Can't spawn here.\n");
14675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 for ( ; incr < 240; incr += 16 )
14676 {
14677 //move if we spawn over a pit
14678 //check each direction
14679
7/12
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 124 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 124 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✓ Branch 11 taken 120 times.
124 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14680 {
14681 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14682
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 x-=incr; break;
14683 }
14684
7/12
✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 120 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 120 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 120 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 28 times.
✓ Branch 11 taken 92 times.
120 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14685 {
14686 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14687
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 x+=incr; break;
14688 }
14689
9/16
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 92 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 92 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 92 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 92 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 92 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 60 times.
92 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14690 {
14691 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14692
2/4
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✗ Branch 3 not taken.
32 x-=incr; y-=incr; break;
14693 }
14694
8/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 60 times.
60 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14695 {
14696 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14697 x+=incr; y-=incr; break;
14698 }
14699
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14700 {
14701 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14702 y -= incr; break;
14703 }
14704
6/12
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 60 times.
60 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14705 {
14706 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14707 y+=incr; break;
14708 }
14709
9/16
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 60 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 60 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 60 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 60 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 60 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 26 times.
✓ Branch 15 taken 34 times.
60 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14710 {
14711 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14712
2/4
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26 times.
✗ Branch 3 not taken.
26 x-=incr; y+=incr; break;
14713 }
14714
8/16
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 34 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 34 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 34 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 34 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 34 times.
34 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14715 {
14716 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14717 x+=incr; y+=incr; break;
14718 }
14719 34 else continue;
14720
14721 }
14722
14723 90 }
14724
14725 239 dir=up;
14726 239 superman=1;
14727 239 fading=fade_invisible;
14728 239 hxofs=1000;
14729 239 segcnt=clk;
14730 239 clk=0;
14731 //set up move history
14732
2/2
✓ Branch 0 taken 239 times.
✓ Branch 1 taken 1691 times.
1930 for(int32_t i=0; i <= (1<<dmisc2); i++)
14733
3/6
✓ Branch 0 taken 1691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1691 times.
✗ Branch 5 not taken.
1691 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14734 239 }
14735
14736 134485 bool eLanmola::animate(int32_t index)
14737 {
14738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 134485 times.
134485 if(switch_hooked) return enemy::animate(index);
14739
2/2
✓ Branch 0 taken 112061 times.
✓ Branch 1 taken 22424 times.
134485 if(clk==0)
14740 {
14741 22424 removearmos(x,y,ffcactivated);
14742 22424 }
14743
14744
2/2
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 132623 times.
134485 if(clk2)
14745 {
14746
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 98 times.
1862 if(--clk2 == 0)
14747 {
14748
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 20 times.
98 if(!dmisc3) //This checks if "segments drop items" isn't true, because if they don't drop items, then only killing the whole thing drops an item.
14749 78 leave_item();
14750
14751 98 stop_bgsfx(index);
14752 98 return true;
14753 }
14754
14755 1764 return false;
14756 }
14757
14758
14759 //this animation style plays ALL KINDS of havoc on the Lanmola segments, since it causes
14760 //the direction AND x,y position of the lanmola to vary in uncertain ways.
14761 //I've added a complete movement history to this enemy to compensate -DD
14762 132623 constant_walk(rate,homing,spw_none);
14763 132623 prevState.pop_front();
14764 132623 prevState.push_front(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix, zfix>(x,y), dir));
14765
14766 // This could cause a crash with Moldorms. I didn't see the same problem
14767 // with Lanmolas, but it looks like it ought to be possible, so here's
14768 // the same solution. - Saf
14769
1/2
✓ Branch 0 taken 132623 times.
✗ Branch 1 not taken.
132623 if(index+segcnt>=guys.Count())
14770 segcnt=guys.Count()-index-1;
14771
14772
2/2
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 599039 times.
731662 for(int32_t i=index+1; i<index+segcnt+1; i++)
14773 {
14774 599039 enemy* segment=((enemy*)guys.spr(i));
14775
14776 // More validation in case segcnt is wrong
14777
1/2
✓ Branch 0 taken 599039 times.
✗ Branch 1 not taken.
599039 if((segment->id&0xFFF)!=(id&0xFFF))
14778 {
14779 segcnt=i-index-1;
14780 break;
14781 }
14782
14783 599039 segment->o_tile=o_tile;
14784 599039 segment->parent_script_UID = this->script_UID;
14785
4/4
✓ Branch 0 taken 132623 times.
✓ Branch 1 taken 466416 times.
✓ Branch 2 taken 19514 times.
✓ Branch 3 taken 113109 times.
599039 if((i==index+segcnt)&&(i!=index+1))
14786 {
14787 113109 segment->dummy_int[1]=1; //tail
14788 113109 }
14789 else
14790 {
14791 485930 segment->dummy_int[1]=0;
14792 }
14793
14794
2/2
✓ Branch 0 taken 598467 times.
✓ Branch 1 taken 572 times.
599039 if(segment->hp <= 0)
14795 {
14796
2/2
✓ Branch 0 taken 572 times.
✓ Branch 1 taken 977 times.
1549 for(int32_t j=i; j<index+segcnt; j++)
14797 {
14798 // Triple-check
14799
1/2
✓ Branch 0 taken 977 times.
✗ Branch 1 not taken.
977 if((((enemy*)guys.spr(j+1))->id&0xFFF)!=(id&0xFFF))
14800 {
14801 segcnt=j-index+1; // Add 1 because of --segcnt below
14802 break;
14803 }
14804 977 zc_swap(((enemy*)guys.spr(j))->hp,((enemy*)guys.spr(j+1))->hp);
14805 977 zc_swap(((enemy*)guys.spr(j))->hclk,((enemy*)guys.spr(j+1))->hclk);
14806 977 }
14807
14808 572 ((enemy*)guys.spr(i))->hclk=33;
14809 572 --segcnt;
14810 572 --i; // Recheck the same index in case multiple segments died at once
14811 572 }
14812 599039 }
14813
14814
2/2
✓ Branch 0 taken 132525 times.
✓ Branch 1 taken 98 times.
132623 if(segcnt==0)
14815 {
14816 98 clk2=19;
14817 98 x=guys.spr(index+1)->x;
14818 98 y=guys.spr(index+1)->y;
14819 98 setmapflag(mTMPNORET);
14820 98 }
14821
14822 //this enemy is invincible.. BUT scripts don't know that, and can "kill" it by setting the hp negative.
14823 //which is... disastrous.
14824 132623 hp = 1;
14825 132623 return enemy::animate(index);
14826 134485 }
14827
14828 1250 esLanmola::esLanmola(zfix X,zfix Y,int32_t Id,int32_t Clk) : eBaseLanmola(X,Y,Id,Clk)
14829 1250 {
14830
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 if( !(editorflags & ENEMY_FLAG5) )
14831 {
14832
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 x=64;
14833
1/2
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
1250 y=80;
14834 1250 }
14835 1250 int32_t incr = 16;
14836 //Don't spawn in pits.
14837
5/8
✓ Branch 0 taken 1250 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1250 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 800 times.
✓ Branch 7 taken 450 times.
1250 if ( m_walkflag_simple(x, y) )
14838 {
14839 //zprint2("Can't spawn here.\n");
14840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
620 for ( ; incr < 240; incr += 16 )
14841 {
14842 //move if we spawn over a pit
14843 //check each direction
14844
7/12
✓ Branch 0 taken 620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 620 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 620 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 620 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 620 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✓ Branch 11 taken 600 times.
620 if ( !m_walkflag_simple(x-incr, y) ) //legaldirs |= 0x1; //left
14845 {
14846 //zprint2("Spawn adjustment: -x (%d)\n", incr);
14847
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 x-=incr; break;
14848 }
14849
7/12
✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 140 times.
✓ Branch 11 taken 460 times.
600 else if ( !m_walkflag_simple(x+incr, y) ) //legaldirs |= 0x2; //right
14850 {
14851 //zprint2("Spawn adjustment: +x (%d)\n", incr);
14852
1/2
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
140 x+=incr; break;
14853 }
14854
9/16
✓ Branch 0 taken 460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 460 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 460 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 460 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 460 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 460 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✓ Branch 15 taken 300 times.
460 else if ( !m_walkflag_simple(x-incr, y-incr) ) //legaldirs |= 0x4; //left-up
14855 {
14856 //zprint2("Spawn adjustment: -x (%d), -y (%d)\n", incr, incr);
14857
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 x-=incr; y-=incr; break;
14858 }
14859
8/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 300 times.
300 else if ( !m_walkflag_simple(x+incr, y-incr) ) //legaldirs |= 0x8; //right-up
14860 {
14861 //zprint2("Spawn adjustment: +x (%d), -y (%d)\n", incr, incr);
14862 x+=incr; y-=incr; break;
14863 }
14864
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y-incr) ) // legaldirs |= 0x10; //up
14865 {
14866 //zprint2("Spawn adjustment: -y (%d)\n", incr);
14867 y -= incr; break;
14868 }
14869
6/12
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✓ Branch 11 taken 300 times.
300 else if ( !m_walkflag_simple(x, y+incr) ) //legaldirs |= 0x20; //down
14870 {
14871 //zprint2("Spawn adjustment: +y (%d)\n", incr);
14872 y+=incr; break;
14873 }
14874
9/16
✓ Branch 0 taken 300 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 300 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 300 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 300 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 300 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 300 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 130 times.
✓ Branch 15 taken 170 times.
300 else if ( !m_walkflag_simple(x-incr, y+incr) ) //legaldirs |= 0x40; //left-down
14875 {
14876 //zprint2("Spawn adjustment: -x (%d), +y (%d)\n", incr, incr);
14877
2/4
✓ Branch 0 taken 130 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 130 times.
✗ Branch 3 not taken.
130 x-=incr; y+=incr; break;
14878 }
14879
8/16
✓ Branch 0 taken 170 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 170 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 170 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 170 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 170 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 170 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 170 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 170 times.
170 else if ( !m_walkflag_simple(x+incr, y+incr) ) //legaldirs |= 0x80; //right-down
14880 {
14881 //zprint2("Spawn adjustment: +x (%d), +y (%d)\n", incr, incr);
14882 x+=incr; y+=incr; break;
14883 }
14884 170 else continue;
14885
14886 }
14887
14888 450 }
14889
14890 1250 hxofs=1000;
14891 1250 hit_width=8;
14892 1250 mainguy=false;
14893 1250 count_enemy=(id<0x2000)?true:false;
14894
14895 //set up move history
14896
2/2
✓ Branch 0 taken 1250 times.
✓ Branch 1 taken 8910 times.
10160 for(int32_t i=0; i <= (1<<dmisc2); i++)
14897
3/6
✓ Branch 0 taken 8910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8910 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8910 times.
✗ Branch 5 not taken.
8910 prevState.push_back(std::pair<std::pair<zfix, zfix>, int32_t>(std::pair<zfix,zfix>(x,y), dir));
14898
14899 1250 bgsfx = -1;
14900 1250 isCore = false;
14901 1250 flags&=~guy_neverret;
14902 1250 }
14903
14904 609335 bool esLanmola::animate(int32_t index)
14905 {
14906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 609335 times.
609335 if(switch_hooked) return enemy::animate(index);
14907 // Shouldn't be possible, but who knows
14908
1/2
✓ Branch 0 taken 609335 times.
✗ Branch 1 not taken.
609335 if(index==0)
14909 dying=true;
14910
14911
2/2
✓ Branch 0 taken 10296 times.
✓ Branch 1 taken 599039 times.
609335 if(dying)
14912 {
14913 10296 xofs=0;
14914
14915
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 8496 times.
10296 if(!dmisc3)
14916 8496 item_set=0;
14917
14918 10296 return Dead(index);
14919 }
14920
14921
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 579729 times.
599039 if(clk>=0)
14922 {
14923 579729 hxofs=4;
14924
14925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 579729 times.
579729 if(!watch)
14926 {
14927 579729 std::pair<std::pair<zfix, zfix>, int32_t> newstate = ((eBaseLanmola*)guys.spr(index-1))->prevState.front();
14928 579729 prevState.pop_front();
14929 579729 prevState.push_back(newstate);
14930 579729 x = newstate.first.first;
14931 579729 y = newstate.first.second;
14932 579729 dir = newstate.second;
14933 579729 }
14934 579729 }
14935
14936 599039 return enemy::animate(index);
14937 609335 }
14938
14939 1513 int32_t esLanmola::takehit(weapon *w, weapon* realweap)
14940 {
14941
2/2
✓ Branch 0 taken 1382 times.
✓ Branch 1 taken 131 times.
1513 if(enemy::takehit(w,realweap))
14942 1382 return (w->id==wSBomb) ? 1 : 2; // force it to wait a frame before checking sword attacks again
14943
14944 131 return 0;
14945 1513 }
14946
14947 610611 void esLanmola::draw(BITMAP *dest)
14948 {
14949 610611 tile=o_tile;
14950 610611 int32_t fdiv = frate/4;
14951
1/2
✓ Branch 0 taken 610611 times.
✗ Branch 1 not taken.
610611 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
14952
14953
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 int32_t f2=get_qr(qr_NEWENEMYTILES)?
14954 610611 efrate:((clk>=(frate>>1))?1:0);
14955
14956
2/2
✓ Branch 0 taken 337533 times.
✓ Branch 1 taken 273078 times.
610611 if(get_qr(qr_NEWENEMYTILES))
14957 {
14958
2/2
✓ Branch 0 taken 68269 times.
✓ Branch 1 taken 269264 times.
337533 if(id>=0x2000)
14959 {
14960 269264 tile+=20;
14961
14962
2/2
✓ Branch 0 taken 209782 times.
✓ Branch 1 taken 59482 times.
269264 if(dummy_int[1]==1)
14963 {
14964 59482 tile+=20;
14965 59482 }
14966 269264 }
14967
14968
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 70158 times.
✓ Branch 2 taken 71956 times.
✓ Branch 3 taken 93557 times.
✓ Branch 4 taken 101862 times.
337533 switch(dir)
14969 {
14970 case up:
14971 70158 flip=0;
14972 70158 break;
14973
14974 case down:
14975 71956 flip=0;
14976 71956 tile+=4;
14977 71956 break;
14978
14979 case left:
14980 93557 flip=0;
14981 93557 tile+=8;
14982 93557 break;
14983
14984 case right:
14985 101862 flip=0;
14986 101862 tile+=12;
14987 101862 break;
14988 }
14989
14990 337533 tile+=f2;
14991 337533 }
14992 else
14993 {
14994
2/2
✓ Branch 0 taken 66631 times.
✓ Branch 1 taken 206447 times.
273078 if(id>=0x2000)
14995 {
14996 206447 tile+=1;
14997 206447 }
14998 }
14999
15000
2/2
✓ Branch 0 taken 19310 times.
✓ Branch 1 taken 591301 times.
610611 if(clk>=0)
15001 591301 enemy::draw(dest);
15002 610611 }
15003
15004 59 eManhandla::eManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,0)
15005 59 {
15006 //these are here to bypass compiler warnings about unused arguments
15007 59 Clk=Clk;
15008 59 superman=1;
15009
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 dir=(zc_oldrand()&7)+8;
15010 59 armcnt=dmisc2?8:4;//((id==eMANHAN)?4:8);
15011
15012
2/2
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 59 times.
327 for(int32_t i=0; i<armcnt; i++)
15013 268 arm[i]=i;
15014
15015 59 fading=fade_blue_poof;
15016 //nets+4680;
15017 59 adjusted=false;
15018 59 SIZEflags = d->SIZEflags; //Probably will be buggy. -Z 12 AUG 2020
15019
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15020 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15021 // al_trace("Enemy txsz:%i\n", txsz);
15022
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15023
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15024
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15025
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15026
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15027
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15028 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15029
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15031 {
15032 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15033 }
15034
15035
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
59 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15036 59 }
15037
15038 30979 bool eManhandla::animate(int32_t index)
15039 {
15040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30979 times.
30979 if(switch_hooked) return enemy::animate(index);
15041
2/2
✓ Branch 0 taken 770 times.
✓ Branch 1 taken 30209 times.
30979 if(dying)
15042 770 return Dead(index);
15043
15044
2/2
✓ Branch 0 taken 28958 times.
✓ Branch 1 taken 1251 times.
30209 if(clk==0)
15045 {
15046 1251 removearmos(x,y,ffcactivated);
15047 1251 }
15048
15049
15050 // check arm status, move dead ones to end of group
15051
2/2
✓ Branch 0 taken 94683 times.
✓ Branch 1 taken 30209 times.
124892 for(int32_t i=0; i<armcnt; i++)
15052 {
15053 94683 enemy* cur_arm = ((enemy*)guys.spr(index+i+1));
15054
3/4
✓ Branch 0 taken 94683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 204 times.
✓ Branch 3 taken 94479 times.
94683 if(!cur_arm || cur_arm->dying)
15055 {
15056
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 204 times.
456 for(int32_t j=i; j<armcnt-1; j++)
15057 {
15058 252 zc_swap(arm[j],arm[j+1]);
15059 252 guys.swap(index+j+1,index+j+2);
15060 252 }
15061
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 36 times.
204 if((editorflags & ENEMY_FLAG6)) //They only did this in 2.10
15062 {
15063 36 leave_item();
15064 36 }
15065 204 --armcnt;
15066 204 --i;
15067 204 continue;
15068 }
15069
2/2
✓ Branch 0 taken 94211 times.
✓ Branch 1 taken 268 times.
94479 if(!adjusted)
15070 {
15071
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 64 times.
268 if(!dmisc2)
15072 {
15073 204 cur_arm->o_tile=o_tile+40;
15074 204 cur_arm->parent_script_UID = this->script_UID;
15075 204 }
15076 else
15077 {
15078 64 cur_arm->o_tile=o_tile+160;
15079 64 cur_arm->parent_script_UID = this->script_UID;
15080 }
15081 268 }
15082 94479 }
15083
15084 30209 adjusted=true;
15085
15086 // move or die
15087
2/2
✓ Branch 0 taken 30166 times.
✓ Branch 1 taken 43 times.
30209 if(armcnt==0)
15088 43 hp=0;
15089 else
15090 {
15091 // Speed starts at 0.5, and increases by 0.5 for each head lost. Max speed is 4.5.
15092
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 step = ((dmisc2 ? 8_zf : 4_zf) - armcnt) * 0.5 + (dstep / 100);
15093
1/2
✓ Branch 0 taken 30166 times.
✗ Branch 1 not taken.
30166 if (step > 4.5_zf) step = 4.5_zf;
15094 30166 int32_t dx1=0, dy1=-8, dx2=15, dy2=15;
15095
15096
2/2
✓ Branch 0 taken 27285 times.
✓ Branch 1 taken 2881 times.
30166 if(!dmisc2)
15097 {
15098
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 27285 times.
107777 for(int32_t i=0; i<armcnt; i++)
15099 {
15100
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15101 {
15102 case 0:
15103 18990 dy1=-24;
15104 18990 break;
15105
15106 case 1:
15107 21427 dy2=31;
15108 21427 break;
15109
15110 case 2:
15111 19973 dx1=-16;
15112 19973 break;
15113
15114 case 3:
15115 20102 dx2=31;
15116 20102 break;
15117 }
15118 80492 }
15119 27285 }
15120 else
15121 {
15122 2881 dx1=-8, dy1=-16, dx2=23, dy2=23;
15123
15124
2/2
✓ Branch 0 taken 13987 times.
✓ Branch 1 taken 2881 times.
16868 for(int32_t i=0; i<armcnt; i++)
15125 {
15126
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4279 times.
✓ Branch 2 taken 3184 times.
✓ Branch 3 taken 2549 times.
✓ Branch 4 taken 3975 times.
13987 switch(arm[i]&3)
15127 {
15128 case 0:
15129 4279 dy1=-32;
15130 4279 break;
15131
15132 case 1:
15133 3184 dy2=39;
15134 3184 break;
15135
15136 case 2:
15137 2549 dx1=-24;
15138 2549 break;
15139
15140 case 3:
15141 3975 dx2=39;
15142 3975 break;
15143 }
15144 13987 }
15145 }
15146
15147 30166 variable_walk_8(rate,homing,hrate,spw_floater,dx1,dy1,dx2,dy2);
15148
15149
2/2
✓ Branch 0 taken 94479 times.
✓ Branch 1 taken 30166 times.
124645 for(int32_t i=0; i<armcnt; i++)
15150 {
15151 94479 zfix dx=(zfix)0,dy=(zfix)0;
15152
15153
2/2
✓ Branch 0 taken 80492 times.
✓ Branch 1 taken 13987 times.
94479 if(!dmisc2)
15154 {
15155
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 18990 times.
✓ Branch 2 taken 21427 times.
✓ Branch 3 taken 19973 times.
✓ Branch 4 taken 20102 times.
80492 switch(arm[i])
15156 {
15157 case 0:
15158 18990 dy=-16;
15159 18990 break;
15160
15161 case 1:
15162 21427 dy=16;
15163 21427 break;
15164
15165 case 2:
15166 19973 dx=-16;
15167 19973 break;
15168
15169 case 3:
15170 20102 dx=16;
15171 20102 break;
15172 }
15173 80492 }
15174 else
15175 {
15176
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 1680 times.
✓ Branch 2 taken 1789 times.
✓ Branch 3 taken 1292 times.
✓ Branch 4 taken 2015 times.
✓ Branch 5 taken 2599 times.
✓ Branch 6 taken 1395 times.
✓ Branch 7 taken 1257 times.
✓ Branch 8 taken 1960 times.
13987 switch(arm[i])
15177 {
15178 case 0:
15179 1680 dy=-24;
15180 1680 dx=-8;
15181 1680 break;
15182
15183 case 1:
15184 1789 dy=24;
15185 1789 dx=8;
15186 1789 break;
15187
15188 case 2:
15189 1292 dx=-24;
15190 1292 dy=8;
15191 1292 break;
15192
15193 case 3:
15194 2015 dx=24;
15195 2015 dy=-8;
15196 2015 break;
15197
15198 case 4:
15199 2599 dy=-24;
15200 2599 dx=8;
15201 2599 break;
15202
15203 case 5:
15204 1395 dy=24;
15205 1395 dx=-8;
15206 1395 break;
15207
15208 case 6:
15209 1257 dx=-24;
15210 1257 dy=-8;
15211 1257 break;
15212
15213 case 7:
15214 1960 dx=24;
15215 1960 dy=8;
15216 1960 break;
15217 }
15218 }
15219
15220 94479 guys.spr(index+i+1)->x = x+dx;
15221 94479 guys.spr(index+i+1)->y = y+dy;
15222 94479 }
15223 }
15224
15225 30209 return enemy::animate(index);
15226 30979 }
15227
15228
15229 1338 int32_t eManhandla::takehit(weapon *w, weapon* realweap)
15230 {
15231 1338 int32_t wpnId = w->id;
15232
15233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1338 times.
1338 if(dying)
15234 return 0;
15235
15236
3/4
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
1338 switch(wpnId)
15237 {
15238 case wBomb:
15239 case wSBomb:
15240 case wSword:
15241 case wHammer:
15242 case wWand:
15243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 448 times.
448 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15244
15245 case wLitBomb:
15246 case wLitSBomb:
15247 case wBait:
15248 case wWhistle:
15249 case wFire:
15250 case wWind:
15251 case wSSparkle:
15252 case wFSparkle:
15253 case wPhantom:
15254 1321 return 0;
15255
15256 case wHookshot:
15257 case wBrang:
15258 sfx(WAV_CHINK,pan(int32_t(x)));
15259 break;
15260
15261 default:
15262
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if (get_qr(qr_MANHANDLA_BLOCK_SFX)) sfx(WAV_EHIT,pan(int32_t(x)));
15263 else sfx(WAV_CHINK,pan(int32_t(x)));
15264
15265 17 }
15266
15267 17 return 1;
15268 1338 }
15269
15270 30977 void eManhandla::draw(BITMAP *dest)
15271 {
15272 30977 tile=o_tile;
15273 30977 int32_t fdiv = frate/4;
15274
1/2
✓ Branch 0 taken 30977 times.
✗ Branch 1 not taken.
30977 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15275
15276
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15277 30977 efrate:((clk>=(frate>>1))?1:0);
15278
15279
2/2
✓ Branch 0 taken 22018 times.
✓ Branch 1 taken 8959 times.
30977 if(get_qr(qr_NEWENEMYTILES))
15280 {
15281
2/2
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 19500 times.
22018 if(!dmisc2)
15282 {
15283
8/9
✓ Branch 0 taken 2465 times.
✓ Branch 1 taken 2274 times.
✓ Branch 2 taken 2799 times.
✓ Branch 3 taken 2974 times.
✓ Branch 4 taken 1879 times.
✓ Branch 5 taken 1895 times.
✓ Branch 6 taken 2025 times.
✓ Branch 7 taken 3189 times.
✗ Branch 8 not taken.
19500 switch(dir-8) //directions get screwed up after 8. *shrug*
15284 {
15285 case up: //u
15286 2465 flip=0;
15287 2465 break;
15288
15289 case l_up: //d
15290 2274 flip=0;
15291 2274 tile+=4;
15292 2274 break;
15293
15294 case l_down: //l
15295 2799 flip=0;
15296 2799 tile+=8;
15297 2799 break;
15298
15299 case left: //r
15300 2974 flip=0;
15301 2974 tile+=12;
15302 2974 break;
15303
15304 case r_down: //ul
15305 1879 flip=0;
15306 1879 tile+=20;
15307 1879 break;
15308
15309 case down: //ur
15310 1895 flip=0;
15311 1895 tile+=24;
15312 1895 break;
15313
15314 case r_up: //dl
15315 2025 flip=0;
15316 2025 tile+=28;
15317 2025 break;
15318
15319 case right: //dr
15320 3189 flip=0;
15321 3189 tile+=32;
15322 3189 break;
15323 }
15324
15325 19500 tile+=f2;
15326 19500 enemy::draw(dest);
15327 19500 } //manhandla 2, big body
15328 else
15329 {
15330
15331
8/9
✗ Branch 0 not taken.
✓ Branch 1 taken 357 times.
✓ Branch 2 taken 483 times.
✓ Branch 3 taken 500 times.
✓ Branch 4 taken 315 times.
✓ Branch 5 taken 196 times.
✓ Branch 6 taken 215 times.
✓ Branch 7 taken 164 times.
✓ Branch 8 taken 288 times.
2518 switch(dir-8) //directions get screwed up after 8. *shrug*
15332 {
15333 case up: //u
15334 357 flip=0;
15335 357 break;
15336
15337 case l_up: //d
15338 483 flip=0;
15339 483 tile+=8;
15340 483 break;
15341
15342 case l_down: //l
15343 500 flip=0;
15344 500 tile+=40;
15345 500 break;
15346
15347 case left: //r
15348 315 flip=0;
15349 315 tile+=48;
15350 315 break;
15351
15352 case r_down: //ul
15353 196 flip=0;
15354 196 tile+=80;
15355 196 break;
15356
15357 case down: //ur
15358 215 flip=0;
15359 215 tile+=88;
15360 215 break;
15361
15362 case r_up: //dl
15363 164 flip=0;
15364 164 tile+=120;
15365 164 break;
15366
15367 case right: //dr
15368 288 flip=0;
15369 288 tile+=128;
15370 288 break;
15371 }
15372
15373 2518 tile+=(f2*2);
15374 2518 xofs-=8;
15375 2518 yofs-=8;
15376 2518 drawblock(dest,15);
15377 2518 xofs+=8;
15378 2518 yofs+=8;
15379 }
15380 22018 }
15381 else
15382 {
15383
2/2
✓ Branch 0 taken 515 times.
✓ Branch 1 taken 8444 times.
8959 if(!dmisc2)
15384 {
15385 8444 enemy::draw(dest);
15386 8444 }
15387 else
15388 {
15389 515 xofs-=8;
15390 515 yofs-=8;
15391 515 enemy::draw(dest);
15392 515 xofs+=16;
15393 515 enemy::draw(dest);
15394 515 yofs+=16;
15395 515 enemy::draw(dest);
15396 515 xofs-=16;
15397 515 enemy::draw(dest);
15398 515 xofs+=8;
15399 515 yofs-=8;
15400 }
15401 }
15402 30977 }
15403
15404 268 esManhandla::esManhandla(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)
15405 268 {
15406 268 id=misc=clk;
15407 268 dir = clk & 3;
15408 268 clk=0;
15409 268 mainguy=count_enemy=false;
15410 268 dummy_bool[0]=false;
15411 268 item_set=0;
15412 268 bgsfx=-1;
15413 268 deadsfx = WAV_EDEAD;
15414 268 flags &= (~guy_neverret);
15415 268 isCore = false;
15416 //Probably will be buggy. -Z 12 AUG 2020
15417 268 SIZEflags = d->SIZEflags;
15418
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
15419 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
15420 // al_trace("Enemy txsz:%i\n", txsz);
15421
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
15422
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
15423
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
15424
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
15425
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
15426
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
15427 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
15428
1/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = d->xofs;
15429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
15430 {
15431 yofs = d->yofs+(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15432 }
15433
15434
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 268 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
268 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = d->zofs;
15435 268 }
15436
15437 98135 bool esManhandla::animate(int32_t index)
15438 {
15439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98135 times.
98135 if(switch_hooked) return enemy::animate(index);
15440
2/2
✓ Branch 0 taken 3656 times.
✓ Branch 1 taken 94479 times.
98135 if(dying)
15441 3656 return Dead(index);
15442
15443
2/2
✓ Branch 0 taken 6029 times.
✓ Branch 1 taken 88450 times.
94479 if(clk==0)
15444 {
15445 6029 removearmos(x,y,ffcactivated);
15446 6029 }
15447
15448
2/2
✓ Branch 0 taken 80858 times.
✓ Branch 1 taken 13621 times.
94479 if(--clk2<=0)
15449 {
15450 13621 clk2=unsigned(zc_oldrand())%5+5;
15451 13621 clk3^=1;
15452 13621 }
15453
15454
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 93728 times.
94479 if(!(zc_oldrand()&127))
15455 {
15456 751 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
15457 751 sfx(wpnsfx(wpn),pan(int32_t(x)));
15458 751 }
15459
15460 94479 return enemy::animate(index);
15461 98135 }
15462
15463 98127 void esManhandla::draw(BITMAP *dest)
15464 {
15465 98127 tile=o_tile;
15466 98127 int32_t fdiv = frate/4;
15467
1/2
✓ Branch 0 taken 98127 times.
✗ Branch 1 not taken.
98127 int32_t efrate = fdiv == 0 ? 0 : clk/fdiv;
15468
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 int32_t f2=get_qr(qr_NEWENEMYTILES)?
15469 98127 efrate:((clk>=(frate>>1))?1:0);
15470
15471
2/2
✓ Branch 0 taken 72946 times.
✓ Branch 1 taken 25181 times.
98127 if(get_qr(qr_NEWENEMYTILES))
15472 {
15473
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 17260 times.
✓ Branch 2 taken 19375 times.
✓ Branch 3 taken 18024 times.
✓ Branch 4 taken 18287 times.
72946 switch(misc&3)
15474 {
15475 case up:
15476 17260 break;
15477
15478 case down:
15479 19375 tile+=4;
15480 19375 break;
15481
15482 case left:
15483 18024 tile+=8;
15484 18024 break;
15485
15486 case right:
15487 18287 tile+=12;
15488 18287 break;
15489 }
15490
15491 72946 tile+=f2;
15492 72946 }
15493 else
15494 {
15495
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 6921 times.
✓ Branch 2 taken 5410 times.
✓ Branch 3 taken 6148 times.
✓ Branch 4 taken 6702 times.
25181 switch(misc&3)
15496 {
15497 case down:
15498 6148 flip=2;
15499
15500 [[fallthrough]];
15501 case up:
15502 13069 tile=(clk3)?188:189;
15503 13069 break;
15504
15505 case right:
15506 6702 flip=1;
15507 [[fallthrough]];
15508
15509 case left:
15510 12112 tile=(clk3)?186:187;
15511 12112 break;
15512 }
15513 }
15514
15515 98127 enemy::draw(dest);
15516 98127 }
15517
15518 94 eGleeok::eGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk) //enemy((zfix)120,(zfix)48,Id,Clk)
15519 94 {
15520
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 if ( !(editorflags & ENEMY_FLAG5) )
15521 {
15522
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 x = 120;
15523
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 y = 48;
15524 94 }
15525 else
15526 {
15527 if ( !(editorflags & ENEMY_FLAG6) )
15528 {
15529 x = X; y = Y;
15530 }
15531 else
15532 {
15533 x = X+8; y = Y;
15534 }
15535 }
15536 94 hzsz = 32; // can't be jumped.
15537 94 flameclk=0;
15538 94 misc=clk; // total head count
15539 94 clk3=clk; // live head count
15540 94 clk=0;
15541 94 clk2=60; // fire ball clock
15542 // hp=(guysbuf[eGLEEOK2+(misc-2)].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[eGLEEOK2+(misc-2)].hp;
15543
1/2
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
94 hp=(guysbuf[id&0xFFF].misc2)*(misc-1)*game->get_hero_dmgmult()+guysbuf[id&0xFFF].hp;
15544 94 dir = down;
15545 94 hxofs=4;
15546 94 hit_width=8;
15547 // frate=17*4;
15548 94 fading=fade_blue_poof;
15549 //nets+5420;
15550
3/4
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 71 times.
✓ Branch 3 taken 23 times.
94 if(get_qr(qr_NEWENEMYTILES))
15551 {
15552 /*
15553 necktile=o_tile+8;
15554 if (dmisc3)
15555 {
15556 necktile+=8;
15557 }
15558 */
15559 71 necktile=o_tile+dmisc6;
15560 71 }
15561 else
15562 {
15563 23 necktile=s_tile;
15564 }
15565 94 }
15566
15567 70509 bool eGleeok::animate(int32_t index)
15568 {
15569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70509 times.
70509 if(switch_hooked) return enemy::animate(index);
15570
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69261 times.
70509 if(dying)
15571 1248 return Dead(index);
15572
15573
2/2
✓ Branch 0 taken 68945 times.
✓ Branch 1 taken 316 times.
69261 if(clk==0)
15574 {
15575 316 removearmos(x,y,ffcactivated);
15576 316 }
15577
15578 // Check if a head was killed somehow...
15579
2/2
✓ Branch 0 taken 35220 times.
✓ Branch 1 taken 34041 times.
69261 if(index+1+clk3>=guys.Count())
15580 34041 clk3=guys.Count()-index-1;
15581
2/2
✓ Branch 0 taken 13804 times.
✓ Branch 1 taken 55457 times.
69261 if(index+1+misc>=guys.Count())
15582 55457 misc=guys.Count()-index-1;
15583
15584 //fix for the "kill all enemies" item
15585
2/2
✓ Branch 0 taken 69255 times.
✓ Branch 1 taken 6 times.
69261 if(hp==-1000)
15586 {
15587
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<clk3; ++i)
15588 {
15589 // I haven't seen this fail, but it seems like it ought to be
15590 // possible, so I'm checking for it. - Saf
15591
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15592 break;
15593 12 ((enemy*)guys.spr(index+i+1))->hp=1; // re-animate each head,
15594 12 ((enemy*)guys.spr(index+i+1))->misc = -1; // disconnect it,
15595 12 ((enemy*)guys.spr(index+i+1))->animate(index+i+1); // let it animate one frame,
15596 12 ((enemy*)guys.spr(index+i+1))->hp=-1000; // and kill it for good
15597 12 }
15598
15599 6 clk3=0;
15600
15601
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 for(int32_t i=0; i<misc; i++)
15602 {
15603
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if((((enemy*)guys.spr(index+i+1))->id&0xFFF)!=(id&0xFFF))
15604 break;
15605 12 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15606 12 }
15607 6 }
15608
15609
2/2
✓ Branch 0 taken 157172 times.
✓ Branch 1 taken 69261 times.
226433 for(int32_t i=0; i<clk3; i++)
15610 {
15611 157172 enemy *head = ((enemy*)guys.spr(index+i+1));
15612 157172 head->dummy_int[1]=necktile;
15613 157172 head->parent_script_UID = this->script_UID;
15614
15615
2/2
✓ Branch 0 taken 103123 times.
✓ Branch 1 taken 54049 times.
157172 if(get_qr(qr_NEWENEMYTILES))
15616 {
15617 103123 head->dummy_int[2]=o_tile+dmisc8; //connected head tile
15618 103123 head->dummy_int[3]=o_tile+dmisc9; //flying head tile
15619 103123 }
15620 else
15621 {
15622 54049 head->dummy_int[2]=necktile+1; //connected head tile
15623 54049 head->dummy_int[3]=necktile+2; //flying head tile
15624 }
15625
15626 157172 head->dmisc5=dmisc5; //neck segments
15627
15628 /*
15629 if (dmisc3)
15630 {
15631 head->dummy_bool[0]=true;
15632 }
15633 */
15634
2/2
✓ Branch 0 taken 154379 times.
✓ Branch 1 taken 2793 times.
157172 if(head->hclk)
15635 {
15636
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 569 times.
2793 if(hclk==0)
15637 {
15638 569 hp -= 1000 - head->hp;
15639 569 hclk = 33;
15640
15641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 569 times.
569 if(hitsfx>0) sfx(hitsfx,pan(int32_t(head->x)));
15642
15643 569 sfx(WAV_EHIT,pan(int32_t(head->x)));
15644 569 }
15645
15646 2793 head->hclk = 0;
15647 2793 }
15648
15649 // Must be set in case of naughty ZScripts
15650 157172 head->hp = 1000;
15651 157172 }
15652
15653
2/2
✓ Branch 0 taken 69069 times.
✓ Branch 1 taken 192 times.
69261 if(hp<=(guysbuf[id&0xFFF].misc2)*(clk3-1)*game->get_hero_dmgmult())
15654 {
15655 192 ((enemy*)guys.spr(index+clk3))->misc = -1; // give signal to fly off
15656 192 hp=(guysbuf[id&0xFFF].misc2)*(--clk3)*game->get_hero_dmgmult();
15657 192 }
15658
15659
2/2
✓ Branch 0 taken 19312 times.
✓ Branch 1 taken 49949 times.
69261 if(!dmisc3)
15660 {
15661
4/4
✓ Branch 0 taken 2801 times.
✓ Branch 1 taken 47148 times.
✓ Branch 2 taken 674 times.
✓ Branch 3 taken 2127 times.
49949 if(++clk2>72 && !(zc_oldrand()&3))
15662 {
15663 674 int32_t i=zc_oldrand()%misc;
15664 674 enemy *head = ((enemy*)guys.spr(index+i+1));
15665 674 addEwpn(head->x,head->y,head->z,wpn,3,wdp,dir,getUID(), 0, head->fakez);
15666 674 sfx(wpnsfx(wpn),pan(int32_t(x)));
15667 674 clk2=0;
15668 674 }
15669 49949 }
15670 else
15671 {
15672
4/4
✓ Branch 0 taken 827 times.
✓ Branch 1 taken 18485 times.
✓ Branch 2 taken 638 times.
✓ Branch 3 taken 189 times.
19312 if(++clk2>100 && !(zc_oldrand()&3))
15673 {
15674 189 enemy *head = ((enemy*)guys.spr(zc_oldrand()%misc+index+1));
15675 189 head->timer=zc_oldrand()%50+50;
15676 189 clk2=0;
15677 189 }
15678 }
15679
15680
3/4
✓ Branch 0 taken 70 times.
✓ Branch 1 taken 69191 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 70 times.
69261 if((hp<=0 && !immortal))
15681 {
15682
2/2
✓ Branch 0 taken 186 times.
✓ Branch 1 taken 70 times.
256 for(int32_t i=0; i<misc; i++)
15683 186 ((enemy*)guys.spr(index+i+1))->misc = -2; // give the signal to disappear
15684
15685
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 67 times.
70 if(flags&guy_neverret) never_return(index);
15686 70 }
15687
15688 69261 return enemy::animate(index);
15689 70509 }
15690
15691 155 int32_t eGleeok::takehit(weapon*,weapon*)
15692 {
15693 155 return 0;
15694 }
15695
15696 70829 void eGleeok::draw(BITMAP *dest)
15697 {
15698 70829 tile=o_tile;
15699
15700
2/2
✓ Branch 0 taken 1248 times.
✓ Branch 1 taken 69581 times.
70829 if(dying)
15701 {
15702 1248 enemy::draw(dest);
15703 1248 return;
15704 }
15705
15706 69581 int32_t f=clk/17;
15707
15708
2/2
✓ Branch 0 taken 46906 times.
✓ Branch 1 taken 22675 times.
69581 if(get_qr(qr_NEWENEMYTILES))
15709 {
15710 // body
15711 46906 xofs=-8;
15712 46906 yofs=32;
15713
15714
4/4
✓ Branch 0 taken 35926 times.
✓ Branch 1 taken 3851 times.
✓ Branch 2 taken 3602 times.
✓ Branch 3 taken 3527 times.
46906 switch(f)
15715
15716 {
15717 case 0:
15718 3851 tile+=0;
15719 3851 break;
15720
15721 case 1:
15722 3602 tile+=2;
15723 3602 break;
15724
15725 case 2:
15726 3527 tile+=4;
15727 3527 break;
15728
15729 default:
15730 35926 tile+=6;
15731 35926 break;
15732 }
15733 46906 }
15734 else
15735 {
15736 // body
15737 22675 xofs=-8;
15738 22675 yofs=32;
15739
15740
3/3
✓ Branch 0 taken 19415 times.
✓ Branch 1 taken 1645 times.
✓ Branch 2 taken 1615 times.
22675 switch(f)
15741 {
15742 case 0:
15743 1645 tile+=0;
15744 1645 break;
15745
15746 case 2:
15747 1615 tile+=4;
15748 1615 break;
15749
15750 default:
15751 19415 tile+=2;
15752 19415 break;
15753 }
15754 }
15755
15756 69581 enemy::drawblock(dest,15);
15757 70829 }
15758
15759 70829 void eGleeok::draw2(BITMAP *dest)
15760 {
15761 // the neck stub
15762 70829 tile=necktile;
15763 70829 xofs=0;
15764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 70829 times.
70829 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15765
15766
2/2
✓ Branch 0 taken 23071 times.
✓ Branch 1 taken 47758 times.
70829 if(get_qr(qr_NEWENEMYTILES))
15767 {
15768 47758 tile+=((clk&24)>>3);
15769 47758 }
15770
15771
3/4
✓ Branch 0 taken 69581 times.
✓ Branch 1 taken 1248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 69581 times.
70829 if(hp > 0 && !dont_draw())
15772 {
15773
4/4
✓ Branch 0 taken 1374 times.
✓ Branch 1 taken 68207 times.
✓ Branch 2 taken 737 times.
✓ Branch 3 taken 637 times.
69581 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
15774 737 sprite::drawcloaked(dest);
15775 else
15776 68844 sprite::draw(dest);
15777 69581 }
15778 70829 }
15779
15780
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
536 esGleeok::esGleeok(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
15781 268 {
15782
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 xoffset=0;
15783
2/4
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
268 yoffset=(zfix)((dmisc5*4+2));
15784 // dummy_bool[0]=false;
15785 268 timer=0;
15786 /* fixing */
15787 268 hp=1000;
15788
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 step=1;
15789 268 item_set=0;
15790 //x=120; y=70;
15791
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 x = xoffset+parent->x;
15792
4/8
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 268 times.
✗ Branch 7 not taken.
268 y = yoffset+parent->y;
15793 268 hxofs=4;
15794 268 hit_width=8;
15795
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 268 times.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
15796 268 clk2=clk; // how int32_t to wait before moving first time
15797 268 clk=0;
15798 268 mainguy=count_enemy=false;
15799
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dir=zc_oldrand();
15800 268 clk3=((dir&2)>>1)+2; // left or right
15801 268 dir&=1; // up or down
15802
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 dmisc5=vbound(dmisc5,1,255);
15803 268 isCore = false;
15804
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 parentCore = parent->getUID();
15805
2/2
✓ Branch 0 taken 1072 times.
✓ Branch 1 taken 268 times.
1340 for(int32_t i=0; i<dmisc5; i++)
15806 {
15807 1072 nxoffset[i] = 0;
15808 1072 nyoffset[i] = 0;
15809
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5);
15810
2/4
✓ Branch 0 taken 1072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1072 times.
✗ Branch 3 not taken.
1072 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5);
15811 1072 }
15812
15813 268 necktile=0;
15814 //TODO compatibility? -DD
15815 /*
15816 for(int32_t i=0; i<4; i++)
15817 {
15818 nx[i]=124;
15819 ny[i]=i*6+48;
15820 }*/
15821 268 bgsfx=-1;
15822 //no need for deadsfx
15823 268 }
15824
15825 202199 bool esGleeok::animate(int32_t index)
15826 {
15827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 202199 times.
202199 if(switch_hooked) return enemy::animate(index);
15828 // don't call removearmos() - it's a segment.
15829
15830 202199 dmisc5=vbound(dmisc5,1,255);
15831
15832
2/2
✓ Branch 0 taken 45213 times.
✓ Branch 1 taken 156986 times.
202199 if(misc == 0)
15833 {
15834 156986 x = (xoffset+parent->x);
15835 156986 y = (yoffset+parent->y);
15836
15837
2/2
✓ Branch 0 taken 627944 times.
✓ Branch 1 taken 156986 times.
784930 for(int32_t i=0; i<dmisc5; i++)
15838 {
15839 627944 nx[i] = ((((i*(int32_t)x) + (dmisc5-i)*((int32_t)parent->x))) /dmisc5) + 3 + nxoffset[i];
15840 627944 ny[i] = ((((i*(int32_t)y) + (dmisc5-i)*((int32_t)parent->y))) /dmisc5) + nyoffset[i];
15841 627944 }
15842 156986 }
15843
15844 // set up the head tiles
15845 // headtile=nets+5588; //5580, actually. must adjust for direction later on
15846 /*
15847 if (dummy_bool[0]) //if this is a flame gleeok
15848 {
15849 headtile+=180;
15850 }
15851 */
15852 202199 headtile=dummy_int[2]; //5580, actually. must adjust for direction later on
15853 202199 flyingheadtile=dummy_int[3];
15854
15855 // set up the neck tiles
15856 202199 necktile=dummy_int[1];
15857
15858
2/2
✓ Branch 0 taken 74462 times.
✓ Branch 1 taken 127737 times.
202199 if(get_qr(qr_NEWENEMYTILES))
15859 {
15860 127737 necktile+=((clk&24)>>3);
15861 127737 }
15862
15863 /*
15864 else
15865 {
15866 necktile=145;
15867 }
15868 */
15869 // ?((dummy_bool[0])?(nets+4052+(16+((clk&24)>>3))):(nets+4040+(8+((clk&24)>>3)))):145)
15870
15871
4/5
✗ Branch 0 not taken.
✓ Branch 1 taken 156986 times.
✓ Branch 2 taken 44881 times.
✓ Branch 3 taken 134 times.
✓ Branch 4 taken 198 times.
202199 switch(misc)
15872 {
15873 case 0: // live head
15874 // set up the attached head tiles
15875 156986 tile=headtile;
15876
15877
2/2
✓ Branch 0 taken 53978 times.
✓ Branch 1 taken 103008 times.
156986 if(get_qr(qr_NEWENEMYTILES))
15878 {
15879 103008 tile+=((clk&24)>>3);
15880 /*
15881 if (dummy_bool[0]) {
15882 tile+=1561;
15883 }
15884 */
15885 103008 }
15886
15887 /*
15888 else
15889 {
15890 tile=146;
15891 }
15892 */
15893
4/4
✓ Branch 0 taken 40101 times.
✓ Branch 1 taken 116885 times.
✓ Branch 2 taken 4484 times.
✓ Branch 3 taken 35617 times.
156986 if(++clk2>=0 && !(clk2&3))
15894 {
15895
2/2
✓ Branch 0 taken 34833 times.
✓ Branch 1 taken 784 times.
35617 if(y<= (int32_t)parent->y + 8) dir=down;
15896
15897
2/2
✓ Branch 0 taken 34879 times.
✓ Branch 1 taken 738 times.
35617 if(y>= (int32_t)parent->y + dmisc5*8) dir = up;
15898
15899
4/4
✓ Branch 0 taken 3728 times.
✓ Branch 1 taken 31889 times.
✓ Branch 2 taken 3626 times.
✓ Branch 3 taken 102 times.
35617 if(y<= (int32_t)parent->y + 10 && !(zc_oldrand()&31))
15900 {
15901 102 dir^=1;
15902 102 }
15903
15904 35617 zfix tempx = x;
15905 35617 zfix tempy = y;
15906
15907 35617 sprite::move(step);
15908 35617 xoffset += (x-tempx);
15909 35617 yoffset += (y-tempy);
15910
15911
2/2
✓ Branch 0 taken 1490 times.
✓ Branch 1 taken 34127 times.
35617 if(clk2>=4)
15912 {
15913 1490 clk3^=1;
15914 1490 clk2=-4;
15915 1490 }
15916 else
15917 {
15918
2/2
✓ Branch 0 taken 33778 times.
✓ Branch 1 taken 349 times.
34127 if(x <= (int32_t)parent->x-(dmisc5*6))
15919 {
15920 349 clk3=right;
15921 349 }
15922
15923
2/2
✓ Branch 0 taken 33743 times.
✓ Branch 1 taken 384 times.
34127 if(x >= (int32_t)parent->x+(dmisc5*6))
15924 {
15925 384 clk3=left;
15926 384 }
15927
15928
4/4
✓ Branch 0 taken 23003 times.
✓ Branch 1 taken 11124 times.
✓ Branch 2 taken 21599 times.
✓ Branch 3 taken 1404 times.
34127 if(y <= (int32_t)parent->y+(dmisc5*6) && !(zc_oldrand()&15))
15929 {
15930 1404 clk3^=1; // x jig
15931 1404 }
15932 else
15933 {
15934
4/4
✓ Branch 0 taken 11258 times.
✓ Branch 1 taken 21465 times.
✓ Branch 2 taken 10924 times.
✓ Branch 3 taken 334 times.
32723 if(y<=(int32_t)parent->y+(dmisc5*4) && !(zc_oldrand()&31))
15935 {
15936 334 clk3^=1; // x switch back
15937 334 }
15938
15939 32723 clk2=-4;
15940 }
15941 }
15942
15943 35617 zc_swap(dir,clk3);
15944 35617 tempx = x;
15945 35617 tempy = y;
15946 35617 sprite::move(step);
15947 35617 xoffset += (x-tempx);
15948 35617 yoffset += (y-tempy);
15949 35617 zc_swap(dir,clk3);
15950
15951
2/2
✓ Branch 0 taken 106851 times.
✓ Branch 1 taken 35617 times.
142468 for(int32_t i=1; i<dmisc5; i++)
15952 {
15953 106851 nxoffset[i] = (zc_oldrand()%3);
15954 106851 nyoffset[i] = (zc_oldrand()%3);
15955 106851 }
15956 35617 }
15957
15958 156986 break;
15959
15960 case 1: // flying head
15961
2/2
✓ Branch 0 taken 2806 times.
✓ Branch 1 taken 42075 times.
44881 if(clk>=0)
15962
15963 {
15964 42075 variable_walk_8(rate,homing,hrate,spw_floater);
15965 42075 }
15966
15967 44881 break;
15968
15969 // the following are messages sent from the main guy...
15970 case -1: // got chopped off
15971 {
15972 134 misc=1;
15973 134 superman=1;
15974 134 hxofs=xofs=0;
15975 134 hit_width=16;
15976 134 cs=8;
15977 134 clk=-24;
15978 134 clk2=40;
15979 134 dir=(zc_oldrand()&7)+8;
15980 134 step=8.0/9.0;
15981 }
15982 134 break;
15983
15984 case -2: // the big guy is dead
15985 198 return true;
15986 }
15987
15988
2/2
✓ Branch 0 taken 189247 times.
✓ Branch 1 taken 12754 times.
202001 if(timer)
15989 {
15990
2/2
✓ Branch 0 taken 11233 times.
✓ Branch 1 taken 1521 times.
12754 if(!(timer%8))
15991 {
15992 1521 FireBreath(true);
15993 1521 }
15994
15995 12754 --timer;
15996 12754 }
15997
15998 202001 return enemy::animate(index);
15999 202199 }
16000
16001 3434 int32_t esGleeok::takehit(weapon *w, weapon* realweap)
16002 {
16003
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3434 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3434 if ((editorflags & ENEMY_FLAG7) && misc == 1)
16004 {
16005 int32_t wpnId = w->id;
16006
16007 if(dying)
16008 return 0;
16009
16010 switch(wpnId)
16011 {
16012 case wLitBomb:
16013 case wLitSBomb:
16014 case wBait:
16015 case wWhistle:
16016 case wFire:
16017 case wWind:
16018 case wSSparkle:
16019 case wFSparkle:
16020 case wPhantom:
16021 return 0;
16022
16023 case wHookshot:
16024 case wBrang:
16025 case wBeam:
16026 case wArrow:
16027 case wMagic:
16028 case wBomb:
16029 case wSBomb:
16030 sfx(WAV_CHINK,pan(int32_t(x)));
16031 break;
16032 default:
16033 break;
16034 }
16035
16036 return 1;
16037 }
16038 else
16039 {
16040 3434 int32_t ret = enemy::takehit(w,realweap);
16041
16042
2/2
✓ Branch 0 taken 641 times.
✓ Branch 1 taken 2793 times.
3434 if(ret==-1)
16043 2793 return 2; // force it to wait a frame before checking sword attacks again
16044
16045 641 return ret;
16046 }
16047 3434 }
16048
16049 202887 void esGleeok::draw(BITMAP *dest)
16050 {
16051 202887 dmisc5=vbound(dmisc5,1,255);
16052
16053
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 157884 times.
✓ Branch 2 taken 45003 times.
202887 switch(misc)
16054 {
16055 case 0: //neck
16056
1/2
✓ Branch 0 taken 157884 times.
✗ Branch 1 not taken.
157884 if(!dont_draw())
16057 {
16058
2/2
✓ Branch 0 taken 473652 times.
✓ Branch 1 taken 157884 times.
631536 for(int32_t i=1; i<dmisc5; i++) //draw the neck
16059 {
16060
2/2
✓ Branch 0 taken 311511 times.
✓ Branch 1 taken 162141 times.
473652 if(get_qr(qr_NEWENEMYTILES))
16061 {
16062
3/4
✓ Branch 0 taken 2211 times.
✓ Branch 1 taken 309300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2211 times.
311511 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16063 2211 overtilecloaked16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,0);
16064 else
16065 309300 overtile16(dest,necktile+(i*dmisc7),nx[i]-4,ny[i]+playing_field_offset,cs,0);
16066 311511 }
16067 else
16068 {
16069
3/4
✓ Branch 0 taken 4278 times.
✓ Branch 1 taken 157863 times.
✓ Branch 2 taken 4278 times.
✗ Branch 3 not taken.
162141 if((tmpscr->flags3&fINVISROOM)&& !(current_item(itype_amulet)))
16070 overtilecloaked16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,0);
16071 else
16072 162141 overtile16(dest,necktile,nx[i]-4,ny[i]+playing_field_offset,cs,0);
16073 }
16074 473652 }
16075 157884 }
16076
16077 157884 break;
16078
16079 case 1: //flying head
16080 45003 tile=flyingheadtile;
16081
16082
2/2
✓ Branch 0 taken 24590 times.
✓ Branch 1 taken 20413 times.
45003 if(get_qr(qr_NEWENEMYTILES))
16083 {
16084 24590 tile+=((clk&24)>>3);
16085 24590 break;
16086 }
16087
16088 /*
16089 else
16090 {
16091 tile=(clk&1)?147:148;
16092 break;
16093 }
16094 */
16095 20413 }
16096 202887 }
16097
16098 202887 void esGleeok::draw2(BITMAP *dest)
16099 {
16100 202887 enemy::draw(dest);
16101 202887 }
16102
16103 53 ePatra::ePatra(zfix X,zfix Y,int32_t Id,int32_t Clk) : enemy(X,Y,Id,Clk)// enemy((zfix)128,(zfix)48,Id,Clk)
16104 53 {
16105
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( !(editorflags & ENEMY_FLAG5) )
16106 {
16107
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 x = 128;
16108
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 y = 48;
16109 53 }
16110 else { x = X; y = Y; }
16111 53 adjusted=false;
16112
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 dir=(zc_oldrand()&7)+8;
16113 //step=0.25;
16114 53 flycnt=dmisc1;
16115 53 flycnt2=dmisc2;
16116 53 loopcnt=0;
16117 53 clk4 = 0;
16118 53 clk5 = 0;
16119 53 clk6 = 0;
16120 53 clk7 = 0;
16121
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
16122 53 SIZEflags = d->SIZEflags;
16123
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16124
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { txsz = 2; extend = 3; }
16125 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16126 // al_trace("Enemy txsz:%i\n", txsz);
16127
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = tysz; if ( tysz > 1 ) extend = 3; }
16128
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) { tysz = 2; extend = 3; }
16129
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = hit_width;
16130
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hit_width = 32;
16131
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = hit_height;
16132
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = hzsz;
16133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = hxofs;
16134
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 else if (dmisc10 == 1) hxofs = -8;
16135
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = hyofs;
16136 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16137
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)xofs;
16138
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
53 else if (dmisc10 == 1) xofs = -8;
16139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16140 {
16141 yofs = (int32_t)yofs; //This seems to be setting to +48 or something with any value set?! -Z
16142 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
16143 }
16144
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
53 else if (dmisc10 == 1) yofs = (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset)-8;
16145
1/2
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
53 if (editorflags & ENEMY_FLAG8) misc = 1;
16146
16147
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
53 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)zofs;
16148
16149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc29 == 0)
16150 {
16151
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16152 {
16153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc29 = (90 / 3);
16154 33 else dmisc29 = (84 / 3);
16155 33 }
16156 else
16157 {
16158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc29 = (90 / 2);
16159 20 else dmisc29 = (84 / 2);
16160 }
16161 53 }
16162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc30 == 0)
16163 {
16164
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16165 {
16166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc30 = (90 / 3)*0.5;
16167 33 else dmisc30 = (84 / 3)*0.5;
16168 33 }
16169 else
16170 {
16171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc30 = (90 / 2)*0.5;
16172 20 else dmisc30 = (84 / 2)*0.5;
16173 }
16174 53 }
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc31 == 0)
16176 {
16177
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16178 {
16179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc31 = (90 / 3)*2;
16180 33 else dmisc31 = (84 / 3)*2;
16181 33 }
16182 else
16183 {
16184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc31 = (90 / 2)*0.5;
16185 20 else dmisc31 = (84 / 2)*0.5;
16186 }
16187 53 }
16188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if (dmisc32 == 0)
16189 {
16190
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 33 times.
53 if(!dmisc4)
16191 {
16192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if (dmisc10) dmisc32 = (90 / 3);
16193 33 else dmisc32 = (84 / 3);
16194 33 }
16195 else
16196 {
16197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
20 if (dmisc10) dmisc32 = (90 / 2)*0.25;
16198 20 else dmisc32 = (84 / 2)*0.25;
16199 }
16200 53 }
16201 53 }
16202
16203 62362 bool ePatra::animate(int32_t index)
16204 {
16205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62362 times.
62362 if(switch_hooked) return enemy::animate(index);
16206
2/2
✓ Branch 0 taken 810 times.
✓ Branch 1 taken 61552 times.
62362 if(dying)
16207 {
16208
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 810 times.
882 for(int32_t i=index+1; i<index+flycnt+flycnt2+1; i++)
16209 {
16210 72 ((enemy*)guys.spr(i))->hp = -1000;
16211 72 }
16212
16213 810 return Dead(index);
16214 }
16215
16216 61552 double basesize = 84;
16217
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc10) basesize = 90;
16218 61552 double halfsize = basesize / 2;
16219 61552 double quartersize = halfsize / 2;
16220 61552 double twothirdsize = (basesize / 3)*2;
16221 61552 double onethirdsize = (basesize / 3);
16222
16223
16224
2/2
✓ Branch 0 taken 47886 times.
✓ Branch 1 taken 13666 times.
61552 if(clk==0)
16225 {
16226 13666 removearmos(x,y,ffcactivated);
16227 13666 }
16228
16229
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 61552 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
61552 if ((clk4 <=0 || clk4%2) && (clk7 <= 0 || clk6 <= -16))
16230 {
16231
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61552 if (!dmisc22 || loopcnt == 0 || (dmisc22 == 1 && loopcnt < 0)) variable_walk_8(rate,homing,hrate,spw_floater);
16232
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (loopcnt < 0) ++clk2;
16233
2/2
✓ Branch 0 taken 60857 times.
✓ Branch 1 taken 695 times.
61552 if(++clk2>basesize)
16234 {
16235 695 clk2=0;
16236
2/12
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 695 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
695 if ((!dmisc26 || (dmisc26 == 1 && flycnt) || (dmisc26 == 2 && !flycnt)) && (!(editorflags & ENEMY_FLAG10) || flycnt || flycnt2))
16237 {
16238
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 334 times.
695 if(loopcnt > 0)
16239 361 --loopcnt;
16240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
334 else if (loopcnt == 0)
16241 {
16242
2/2
✓ Branch 0 taken 206 times.
✓ Branch 1 taken 128 times.
334 if((misc%dmisc6)==0)
16243 {
16244
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if (dmisc21 > 0) loopcnt=-dmisc21;
16245 128 else loopcnt=dmisc7;
16246 128 }
16247 334 }
16248 else if (loopcnt == -1) loopcnt=dmisc7;
16249 else ++loopcnt;
16250
16251
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
695 if (!(editorflags & ENEMY_FLAG9) || loopcnt == 0) ++misc;
16252 695 }
16253 else
16254 {
16255 loopcnt = 0;
16256 misc = 1;
16257 }
16258 695 }
16259 61552 }
16260
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk4 > 0) --clk4;
16261
16262
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 < 0)
16263 {
16264 if (dmisc5 == 1 || dmisc5 == 3)
16265 {
16266 if (get_qr(qr_NEWENEMYTILES))
16267 {
16268 if (clk7 <= 0 || clk6 != -16) ++clk6;
16269 if (clk6 == 0) o_tile=d->e_tile;
16270 else
16271 {
16272 if (clk6 >= -16) o_tile=d->e_tile + (IsBigAnim() ? 320 : 80);
16273 else o_tile=d->e_tile + (IsBigAnim() ? 160 : 40);
16274 }
16275 }
16276 else clk6 = 0;
16277 }
16278 }
16279
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk6;
16280
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk5 < 0) ++clk5;
16281
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 else if (dmisc19) ++clk5;
16282
16283
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 61552 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
61552 if (clk7 > 0 && clk6 >= -16) --clk7;
16284
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (clk6 > 0) clk7 = 0;
16285
16286
2/2
✓ Branch 0 taken 244144 times.
✓ Branch 1 taken 61552 times.
305696 for(int32_t i=index+1; i<index+flycnt+1; i++)
16287 {
16288 //outside ring
16289
2/2
✓ Branch 0 taken 243720 times.
✓ Branch 1 taken 424 times.
244144 if(!adjusted)
16290 {
16291
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 152 times.
424 if(get_qr(qr_NEWENEMYTILES))
16292 {
16293 272 ((enemy*)guys.spr(i))->o_tile=d->e_tile+dmisc8;
16294 272 enemy *s = ((enemy*)guys.spr(i));
16295 272 s->parent_script_UID = this->script_UID;
16296 272 }
16297 else
16298 {
16299 152 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16300 152 enemy *s = ((enemy*)guys.spr(i));
16301 152 s->parent_script_UID = this->script_UID;
16302 }
16303
16304 424 ((enemy*)guys.spr(i))->cs=dmisc9;
16305 424 ((enemy*)guys.spr(i))->hp=dmisc3;
16306 424 }
16307
16308
2/2
✓ Branch 0 taken 361 times.
✓ Branch 1 taken 243783 times.
244144 if(((enemy*)guys.spr(i))->hp <= 0)
16309 {
16310
2/2
✓ Branch 0 taken 1294 times.
✓ Branch 1 taken 361 times.
1655 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16311 {
16312 1294 guys.swap(j,j+1);
16313 1294 }
16314
16315
3/4
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 317 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
361 if (--flycnt == 0 && dmisc23 != 0) step += zslongToFix(dmisc23*100);
16316 361 }
16317 else
16318 {
16319 243783 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16320
1/2
✓ Branch 0 taken 243783 times.
✗ Branch 1 not taken.
243783 double a2 = (clk2-pos2*(double)basesize/(dmisc1 == 0 ? 1 : dmisc1))*PI/halfsize;
16321
16322
2/2
✓ Branch 0 taken 86967 times.
✓ Branch 1 taken 156816 times.
243783 if(!dmisc4) //Big Ring
16323 {
16324 //maybe playing_field_offset here?
16325
2/2
✓ Branch 0 taken 84872 times.
✓ Branch 1 taken 71944 times.
156816 if(loopcnt>0)
16326 {
16327
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc31) - zc::math::Sin(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16328
1/2
✓ Branch 0 taken 84872 times.
✗ Branch 1 not taken.
84872 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc31) + zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1))*((int64_t)abs(dmisc31)-abs(dmisc29));
16329 84872 }
16330 else
16331 {
16332 71944 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16333 71944 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16334 }
16335
16336 156816 temp_x=guys.spr(i)->x;
16337 156816 temp_y=guys.spr(i)->y;
16338 156816 }
16339 else //Oval
16340 {
16341 86967 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16342 86967 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc29);
16343
16344
2/2
✓ Branch 0 taken 50142 times.
✓ Branch 1 taken 36825 times.
86967 if(loopcnt>0)
16345 {
16346 50142 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc29);
16347
1/2
✓ Branch 0 taken 50142 times.
✗ Branch 1 not taken.
50142 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1 == 0 ? 1 : dmisc1)))*abs(dmisc31);
16348 50142 }
16349 else
16350 {
16351 36825 guys.spr(i)->x = circle_x;
16352 36825 guys.spr(i)->y = circle_y;
16353 }
16354
16355 86967 temp_x=circle_x;
16356 86967 temp_y=circle_y;
16357 }
16358
16359 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16360 243783 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16361
16362
4/4
✓ Branch 0 taken 46216 times.
✓ Branch 1 taken 197567 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30939 times.
243783 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16363 {
16364 30939 guys.spr(i)->dir=l_down;
16365 30939 }
16366
4/4
✓ Branch 0 taken 46264 times.
✓ Branch 1 taken 166580 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30987 times.
212844 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16367 {
16368 30987 guys.spr(i)->dir=left;
16369 30987 }
16370
4/4
✓ Branch 0 taken 45998 times.
✓ Branch 1 taken 135859 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30721 times.
181857 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16371 {
16372 30721 guys.spr(i)->dir=l_up;
16373 30721 }
16374
4/4
✓ Branch 0 taken 45644 times.
✓ Branch 1 taken 105492 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30367 times.
151136 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16375 {
16376 30367 guys.spr(i)->dir=up;
16377 30367 }
16378
4/4
✓ Branch 0 taken 45419 times.
✓ Branch 1 taken 75350 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30142 times.
120769 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16379 {
16380 30142 guys.spr(i)->dir=r_up;
16381 30142 }
16382
4/4
✓ Branch 0 taken 45271 times.
✓ Branch 1 taken 45356 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 29994 times.
90627 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16383 {
16384 29994 guys.spr(i)->dir=right;
16385 29994 }
16386
4/4
✓ Branch 0 taken 45354 times.
✓ Branch 1 taken 15279 times.
✓ Branch 2 taken 15277 times.
✓ Branch 3 taken 30077 times.
60633 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16387 {
16388 30077 guys.spr(i)->dir=r_down;
16389 30077 }
16390 else
16391 {
16392 30556 guys.spr(i)->dir=down;
16393 }
16394
16395 243783 guys.spr(i)->x += x;
16396 243783 guys.spr(i)->y += y;
16397 }
16398 244144 }
16399
16400
7/22
✓ Branch 0 taken 39936 times.
✓ Branch 1 taken 21616 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39936 times.
✓ Branch 4 taken 5813 times.
✓ Branch 5 taken 15803 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 5813 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 15803 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
61552 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==1 || dmisc5== 3) && (!dmisc25 || (dmisc25 == 1 && !flycnt && !flycnt2) || (dmisc25 == 2 && (flycnt || flycnt2)) || (dmisc25 == 3 && flycnt2 && !flycnt)))
16401 {
16402 15803 int timeneeded = 48;
16403 15803 int patbreath = (zc_oldrand()%50+50);
16404
2/2
✓ Branch 0 taken 11961 times.
✓ Branch 1 taken 3842 times.
15803 if ((patbreath % 4) == 0) ++patbreath;
16405
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratBREATH)
16406 {
16407 timeneeded = 48 + patbreath;
16408 }
16409
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (dmisc28 == patratSTREAM)
16410 {
16411 timeneeded = 48 + 96;
16412 }
16413
4/14
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15803 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 133 times.
✓ Branch 11 taken 133 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
15803 if (((((dmisc18 > 0 || ((editorflags & ENEMY_FLAG10) && !flycnt && !flycnt2)) && !(zc_oldrand() % zc_max(dmisc18, 1))) || //New 1/N chance
16414
2/2
✓ Branch 0 taken 15803 times.
✓ Branch 1 taken 133 times.
15936 (dmisc18 == 0 && !(zc_oldrand()&127)) //Old hardcoded firing chance
16415
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 15670 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
15936 || (dmisc18 == -1 && loopcnt > 0 && (clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16416 || (clk4 == 10 && (editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)))))
16417 133 && (clk6 >= 0) //if not in the middle of firing...
16418 133 && clk6 >= dmisc19) //if over the set cooldown between shots...
16419
2/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
133 && ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > timeneeded)) || dmisc18 == -1)) //And lastly, if not in danger of starting a loop during the attack.
16420 {
16421
1/3
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
133 switch(dmisc28)
16422 {
16423 case patratSTREAM:
16424 {
16425 clk7 = 97;
16426 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16427 else clk6 = 0;
16428 break;
16429 }
16430 case patratBREATH:
16431 {
16432 clk7 = patbreath;
16433 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) clk6 = -48;
16434 else clk6 = 0;
16435 break;
16436 }
16437 default:
16438 {
16439
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
133 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16440 {
16441 clk6 = -48;
16442 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16443 }
16444 else
16445 {
16446 133 clk6 = 0;
16447
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16448 133 FirePatraWeapon();
16449 }
16450 133 break;
16451 }
16452 } //ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16453 133 }
16454
1/2
✓ Branch 0 taken 15803 times.
✗ Branch 1 not taken.
15803 if (clk6 < 0)
16455 {
16456 switch(dmisc28)
16457 {
16458 case patratSTREAM:
16459 {
16460 if (clk7 > 0 && (clk7 % 12) == 0) FirePatraWeapon();
16461 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16462 break;
16463 }
16464 case patratBREATH:
16465 {
16466 if (clk7 > 0 && (clk7 % 4) == 0) FirePatraWeapon();
16467 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16468 break;
16469 }
16470 default:
16471 {
16472 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && clk6 == -16)
16473 {
16474 FirePatraWeapon();
16475 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk6) + 16;
16476 }
16477 break;
16478 }
16479 }
16480 }
16481 15803 }
16482
16483 61552 int randattempts = 0;
16484 61552 int randeye = 0;
16485
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if (flycnt2 > 0)
16486 {
16487 16602 do
16488 {
16489
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✓ Branch 2 taken 15935 times.
✓ Branch 3 taken 667 times.
16602 randeye = ((flycnt2 > 0) ? (zc_oldrand() % zc_max(1, flycnt2)) : 0);
16490 16602 randeye += (index + flycnt + 1);
16491 16602 ++randattempts;
16492
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16602 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16602 times.
16602 } while (((esPatra*)guys.spr(randeye))->clk5 < 0 && randattempts < 10);
16493 16602 }
16494 61552 bool dofire = false;
16495
1/2
✓ Branch 0 taken 61552 times.
✗ Branch 1 not taken.
61552 if (dmisc20)
16496 {
16497 if ((dmisc18 > 0 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16498 (dmisc18 == 0 && !(zc_oldrand()&127)) ||
16499 (dmisc18 == -1 && (loopcnt > 0 || dmisc20 == 4) && ((clk2 == round(halfsize) && (!(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES)) && dmisc20 != 2 && dmisc20 != 4)
16500 || (clk2 == 10 && dmisc20 != 4 && ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) || dmisc20 == 2))
16501 || ((((((misc%dmisc6) == 0 && (loopcnt == 0 && !dmisc21)) || loopcnt > 1 || loopcnt == -1) && clk2 <= 53 && clk2 >= 51 && (editorflags & ENEMY_FLAG3)) || (!(editorflags & ENEMY_FLAG3) && loopcnt > 0 && clk2 == 1)) && dmisc20 == 4))))
16502 {
16503 if (clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16504 {
16505 if (clk5 >= dmisc19)
16506 {
16507 if ((!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16508 (dmisc20 == 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + (int64_t(12)*flycnt2))) ||
16509 (dmisc20 == 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > ((int64_t)48 + 96)) ||
16510 (dmisc20 != 2 && dmisc20 != 4 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48)))
16511 || dmisc18 == -1)
16512 dofire = true;
16513 }
16514 }
16515 }
16516 }
16517
2/2
✓ Branch 0 taken 44950 times.
✓ Branch 1 taken 16602 times.
61552 if(flycnt2)
16518 {
16519
2/2
✓ Branch 0 taken 119975 times.
✓ Branch 1 taken 16602 times.
136577 for(int32_t i=index+flycnt+1; i<index+flycnt+flycnt2+1; i++)//inner ring
16520 {
16521
2/2
✓ Branch 0 taken 119887 times.
✓ Branch 1 taken 88 times.
119975 if(!adjusted)
16522 {
16523 88 ((enemy*)guys.spr(i))->hp=12*game->get_hero_dmgmult();
16524
16525
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(get_qr(qr_NEWENEMYTILES))
16526 {
16527
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16528 {
16529
2/3
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
88 switch(dmisc5)
16530 {
16531 // Center eye shoots projectiles; make room for its firing tiles
16532 case 1:
16533 case 3:
16534 48 ((enemy*)guys.spr(i))->o_tile=d->e_tile+120;
16535 48 break;
16536
16537 // Center eyes does not shoot; use tiles two rows below for inner eyes.
16538 default:
16539 case 2:
16540 40 ((enemy*)guys.spr(i))->o_tile=d->e_tile+40;
16541 40 break;
16542 }
16543 88 }
16544 else ((enemy*)guys.spr(i))->o_tile = d->s_tile;
16545 88 }
16546 else
16547 {
16548 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
16549 }
16550
16551 88 ((enemy*)guys.spr(i))->cs=dmisc9;
16552
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if (dmisc27) ((enemy*)guys.spr(i))->hp=dmisc27;
16553 88 }
16554
16555
2/2
✓ Branch 0 taken 94136 times.
✓ Branch 1 taken 25839 times.
119975 if(flycnt>0)
16556 {
16557 94136 ((enemy*)guys.spr(i))->superman=true;
16558 94136 }
16559 else
16560 {
16561 25839 ((enemy*)guys.spr(i))->superman=false;
16562 }
16563
16564
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 119903 times.
119975 if(((enemy*)guys.spr(i))->hp <= 0)
16565 {
16566
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 72 times.
216 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
16567 {
16568 144 guys.swap(j,j+1);
16569 144 }
16570
16571
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 63 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
72 if (--flycnt2 == 0 && dmisc24 != 0) step += zslongToFix(dmisc24*100);
16572 72 }
16573 else
16574 {
16575 119903 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
16576
1/2
✓ Branch 0 taken 119903 times.
✗ Branch 1 not taken.
119903 double a2 = ((clk2-pos2*basesize/(dmisc2==0 ? 1 : dmisc2))*PI/(halfsize));
16577
16578
2/2
✓ Branch 0 taken 7259 times.
✓ Branch 1 taken 112644 times.
119903 if(dmisc4==0)
16579 {
16580
2/2
✓ Branch 0 taken 58268 times.
✓ Branch 1 taken 54376 times.
112644 if(loopcnt>0)
16581 {
16582
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc32) - zc::math::Sin(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16583
1/2
✓ Branch 0 taken 58268 times.
✗ Branch 1 not taken.
58268 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc32) + zc::math::Cos(pos2*PI*2/(dmisc2==0?1:dmisc2))*((int64_t)abs(dmisc32)-abs(dmisc30));
16584 58268 }
16585 else
16586 {
16587 54376 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16588 54376 guys.spr(i)->y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16589 }
16590
16591 112644 temp_x=guys.spr(i)->x;
16592 112644 temp_y=guys.spr(i)->y;
16593 112644 }
16594 else
16595 {
16596 7259 circle_x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16597 7259 circle_y = -zc::math::Sin(a2+PI/2)*abs(dmisc30);
16598
16599
2/2
✓ Branch 0 taken 3965 times.
✓ Branch 1 taken 3294 times.
7259 if(loopcnt>0)
16600 {
16601 3965 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*abs(dmisc30);
16602
1/2
✓ Branch 0 taken 3965 times.
✗ Branch 1 not taken.
3965 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc2 == 0 ? 1 : dmisc2)))*abs(dmisc32);
16603 3965 }
16604 else
16605 {
16606 3294 guys.spr(i)->x = circle_x;
16607 3294 guys.spr(i)->y = circle_y;
16608 }
16609
16610 7259 temp_x=circle_x;
16611 7259 temp_y=circle_y;
16612 }
16613
16614 double _MSVC2022_tmp1, _MSVC2022_tmp2;
16615 119903 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
16616
16617
4/4
✓ Branch 0 taken 22203 times.
✓ Branch 1 taken 97700 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14941 times.
119903 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
16618 {
16619 14941 guys.spr(i)->dir=l_down;
16620 14941 }
16621
4/4
✓ Branch 0 taken 22190 times.
✓ Branch 1 taken 82772 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14928 times.
104962 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
16622 {
16623 14928 guys.spr(i)->dir=left;
16624 14928 }
16625
4/4
✓ Branch 0 taken 22199 times.
✓ Branch 1 taken 67835 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14937 times.
90034 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
16626 {
16627 14937 guys.spr(i)->dir=l_up;
16628 14937 }
16629
4/4
✓ Branch 0 taken 22258 times.
✓ Branch 1 taken 52839 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 14996 times.
75097 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
16630 {
16631 14996 guys.spr(i)->dir=up;
16632 14996 }
16633
4/4
✓ Branch 0 taken 22303 times.
✓ Branch 1 taken 37798 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15041 times.
60101 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
16634 {
16635 15041 guys.spr(i)->dir=r_up;
16636 15041 }
16637
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 22763 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
45060 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
16638 {
16639 15035 guys.spr(i)->dir=right;
16640 15035 }
16641
4/4
✓ Branch 0 taken 22297 times.
✓ Branch 1 taken 7728 times.
✓ Branch 2 taken 7262 times.
✓ Branch 3 taken 15035 times.
30025 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
16642 {
16643 15035 guys.spr(i)->dir=r_down;
16644 15035 }
16645 else
16646 {
16647 14990 guys.spr(i)->dir=down;
16648 }
16649
16650 119903 guys.spr(i)->x += x;
16651 119903 guys.spr(i)->y = y-guys.spr(i)->y;
16652
16653
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 119903 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 81826 times.
✓ Branch 5 taken 38077 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 81826 times.
119903 if((wpn>wEnemyWeapons || (wpn >= wScript1 && wpn <= wScript10)) && (dmisc5==2 || dmisc5== 3))
16654 {
16655 /*
16656 if(!(zc_oldrand()&127))
16657 {
16658 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID());
16659 sfx(wpnsfx(wpn),pan(int32_t(x)));
16660 }
16661 */
16662
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
38077 if (((esPatra*)guys.spr(i))->clk5 < 0 && (editorflags & ENEMY_FLAG3))
16663 {
16664 if (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16) ++((esPatra*)guys.spr(i))->clk5;
16665 if (get_qr(qr_PATRAS_USE_HARDCODED_OFFSETS))
16666 {
16667 if (dmisc5 == 3)
16668 {
16669 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16670 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+200;
16671 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+160;
16672 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16673 }
16674 else
16675 {
16676 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16677 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+120;
16678 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->e_tile+80;
16679 else ((esPatra*)guys.spr(i))->o_tile=d->e_tile+40;
16680 }
16681 }
16682 else
16683 {
16684 if (((esPatra*)guys.spr(i))->clk5 >= 0) ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16685 else if (((esPatra*)guys.spr(i))->clk5 >= -16) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+80;
16686 else if (((esPatra*)guys.spr(i))->clk5 >= -48) ((esPatra*)guys.spr(i))->o_tile=d->s_tile+40;
16687 else ((esPatra*)guys.spr(i))->o_tile=d->s_tile;
16688 }
16689 }
16690
4/6
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 38077 times.
✓ Branch 4 taken 38077 times.
✓ Branch 5 taken 38077 times.
38077 else if ((dmisc19 || ((esPatra*)guys.spr(i))->clk5) && (((esPatra*)guys.spr(i))->clk4 <= 0 || ((esPatra*)guys.spr(i))->clk5 != -16)) ++((esPatra*)guys.spr(i))->clk5;
16691
1/2
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
38077 if (((esPatra*)guys.spr(i))->clk4 > 0) --((esPatra*)guys.spr(i))->clk4;
16692
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if (!dmisc25 || (dmisc25 == 1 && !((enemy*)guys.spr(i))->superman) || ((dmisc25 == 2 || dmisc25 == 3) && ((enemy*)guys.spr(i))->superman))
16693 {
16694
1/5
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
38077 switch(dmisc20) //Patra Attack Patterns
16695 {
16696 case 4: //Single one rapidfires
16697 {
16698 if (dofire && i == randeye)
16699 {
16700 ((esPatra*)guys.spr(i))->clk5 = -16;
16701 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES)) ((esPatra*)guys.spr(i))->clk5 = -48;
16702 ((esPatra*)guys.spr(i))->clk4 = 96;
16703 clk5 = -3;
16704 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16705 }
16706 if (((esPatra*)guys.spr(i))->clk5 == -16 && (((esPatra*)guys.spr(i))->clk4 % 12) == 0)
16707 {
16708 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16709 sfx(wpnsfx(wpn),pan(int32_t(x)));
16710 }
16711 break;
16712 }
16713 case 3: //Ring
16714 {
16715 if (dofire)
16716 {
16717 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16718 {
16719 ((esPatra*)guys.spr(i))->clk5 = -48;
16720 clk5 = -48;
16721 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16722 }
16723 else
16724 {
16725 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16726 sfx(wpnsfx(wpn),pan(int32_t(x)));
16727 int32_t m=Ewpns.Count()-1;
16728 weapon *ew = (weapon*)(Ewpns.spr(m));
16729
16730 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16731 ((esPatra*)guys.spr(i))->clk5 = 0;
16732 clk5 = 0;
16733 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16734 }
16735 }
16736 if (((esPatra*)guys.spr(i))->clk5 == -16)
16737 {
16738 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16739 sfx(wpnsfx(wpn),pan(int32_t(x)));
16740 int32_t m=Ewpns.Count()-1;
16741 weapon *ew = (weapon*)(Ewpns.spr(m));
16742
16743 ew->setAngle(atan2(double(HeroY()-y),double(HeroX()-x)));
16744 }
16745 break;
16746 }
16747 case 2: //one after another
16748 {
16749 if (dofire)
16750 {
16751 ((esPatra*)guys.spr(i))->clk5 = -48 - (12*(i-(index+flycnt+1)));
16752 clk5 = -48 - (12*flycnt2);
16753 if (editorflags & ENEMY_FLAG6) clk4 = abs(clk5) + 16;
16754 }
16755 if (((esPatra*)guys.spr(i))->clk5 == -16)
16756 {
16757 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16758 sfx(wpnsfx(wpn),pan(int32_t(x)));
16759 }
16760 break;
16761 }
16762 case 1: //random one eye
16763 {
16764 if (dofire && i == randeye)
16765 {
16766 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16767 {
16768 ((esPatra*)guys.spr(i))->clk5 = -48;
16769 clk5 = -48;
16770 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16771 }
16772 else
16773 {
16774 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16775 sfx(wpnsfx(wpn),pan(int32_t(x)));
16776 ((esPatra*)guys.spr(i))->clk5 = 0;
16777 clk5 = 0;
16778 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16779 }
16780 }
16781 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16782 {
16783 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, guys.spr(i)->fakez);
16784 sfx(wpnsfx(wpn),pan(int32_t(x)));
16785 }
16786 break;
16787 }
16788 default: //old behavior, all eyes can fire any time
16789 {
16790
3/8
✓ Branch 0 taken 38077 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 292 times.
✓ Branch 5 taken 292 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
38077 if ((((dmisc18 && !(zc_oldrand() % zc_max(dmisc18, 1))) ||
16791
3/6
✓ Branch 0 taken 38077 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 292 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 (!dmisc18 && !(zc_oldrand()&127))) && (((esPatra*)guys.spr(i))->clk5 >= 0 || !(editorflags & ENEMY_FLAG3) || !get_qr(qr_NEWENEMYTILES))
16792
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 && ((esPatra*)guys.spr(i))->clk5 >= dmisc19) && (!(editorflags & ENEMY_FLAG7) || (loopcnt == 0 &&
16793 (dmisc20 != 2 && (basesize*((int64_t)dmisc6 - (misc%dmisc6))) > 48))))
16794 {
16795
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
292 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES))
16796 {
16797 ((esPatra*)guys.spr(i))->clk5 = -48;
16798 if (editorflags & ENEMY_FLAG6) clk4 = 64;
16799 }
16800 else
16801 {
16802 292 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16803 292 sfx(wpnsfx(wpn),pan(int32_t(x)));
16804 292 ((esPatra*)guys.spr(i))->clk5 = 0;
16805
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if (editorflags & ENEMY_FLAG6) clk4 = 16;
16806 }
16807 292 }
16808
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 38077 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
38661 if ((editorflags & ENEMY_FLAG3) && get_qr(qr_NEWENEMYTILES) && ((esPatra*)guys.spr(i))->clk5 == -16)
16809 {
16810 addEwpn(guys.spr(i)->x,guys.spr(i)->y,guys.spr(i)->z,wpn,3,wdp,dir,getUID(), 0, fakez);
16811 sfx(wpnsfx(wpn),pan(int32_t(x)));
16812 }
16813 38077 break;
16814 }
16815 }
16816 38077 }
16817 38077 }
16818
16819 }
16820 119975 }
16821 16602 }
16822
16823 61552 adjusted=true;
16824 61552 return enemy::animate(index);
16825 62362 }
16826
16827 133 void ePatra::FirePatraWeapon()
16828 { //.707
16829 133 int32_t xoff = 0;
16830 133 int32_t yoff = 0;
16831
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_WIDTH )
16832 {
16833 xoff += (hit_width/2)-8;
16834 //Z_scripterrlog("width flag enabled. xoff = %d\n", xoff);
16835 }
16836
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if ( SIZEflags&guyflagOVERRIDE_HIT_HEIGHT )
16837 {
16838 yoff += (hit_height/2)-8;
16839 //Z_scripterrlog("width flag enabled. yoff = %d\n", yoff);
16840 }
16841 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16842
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
133 switch (dmisc28)
16843 {
16844 case patrat8SHOT: //Fire Wizzrobe
16845 case patrat4SHOTDIAG:
16846 case patrat4SHOTRAND:
16847 if (dmisc28 != patrat4SHOTRAND || (zc_oldrand()%2)) //if it's the 4 shot rand type, only let it through half the time. Break is within so it doesn't do both, but if it skips this one it'll always do the other one.
16848 {
16849 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_up,-1, getUID(),false));
16850 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16851 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16852 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16853
16854 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,l_down,-1, getUID(),false));
16855 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16856 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16857 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16858
16859 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_up,-1, getUID(),false));
16860 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16861 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16862 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16863
16864 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,r_down,-1, getUID(),false));
16865 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16866 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16867 if (wpn != ewFlame && wpn != ewFlame2) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= .707; //Fire already does this internall for asome bizarre reason.
16868
16869 if (dmisc28 == patrat4SHOTDIAG || dmisc28 == patrat4SHOTRAND) break;
16870 }
16871
16872 [[fallthrough]];
16873 case patrat4SHOTCARD: //Stalfos 3
16874 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,up,-1, getUID(),false));
16875 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16876 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16877 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,down,-1, getUID(),false));
16878 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16879 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16880 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,left,-1, getUID(),false));
16881 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16882 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16883 Ewpns.add(new weapon(x+xoff,y+yoff,z,wpn,1,wdp,right,-1, getUID(),false));
16884 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
16885 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->moveflags &= ~FLAG_CAN_PITFALL; //No falling in pits
16886 break;
16887
16888 default:
16889 133 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16890
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if (dmisc28 == patratBREATH) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle += (zc_rand(20,-20)/100.0)*PI;
16891 133 double anglestore = ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle;
16892
3/6
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 133 times.
133 if (dmisc28 == patrat1SHOTFAST || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16893
4/8
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 133 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 133 times.
133 if (dmisc28 == patrat3SHOT || dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16894 {
16895 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16896 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.46364761;
16897 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16898 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16899 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16900 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.46364761;
16901 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.1180;
16902 if (dmisc28 == patrat3SHOTFAST || dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16903 if (dmisc28 == patrat5SHOT || dmisc28 == patrat5SHOTFAST)
16904 {
16905 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16906 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore + (double)0.78539816;
16907 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16908 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16909 addEwpn(x,y,z,wpn,3,wdp,dir,getUID(), 0, fakez);
16910 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->angle = anglestore - (double)0.78539816;
16911 ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step += 0.4142;
16912 if (dmisc28 == patrat5SHOTFAST) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->step *= 2;
16913 }
16914 }
16915 133 break;
16916
16917 }
16918 133 sfx(wpnsfx(wpn),pan(int32_t(x)));
16919 //+0.46364761
16920 //11.80
16921 133 }
16922
16923 124918 void ePatra::draw(BITMAP *dest)
16924 {
16925 124918 tile=o_tile;
16926 124918 update_enemy_frame();
16927 124918 enemy::draw(dest);
16928 124918 }
16929
16930 int32_t ePatra::defend(int32_t wpnId, int32_t *power, int32_t edef)
16931 {
16932 int32_t ret = enemy::defend(wpnId, power, edef);
16933
16934 if(ret < 0 && (flycnt||flycnt2))
16935 return 0;
16936
16937 return ret;
16938 }
16939
16940 908 int32_t ePatra::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
16941 {
16942 908 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
16943
16944
6/6
✓ Branch 0 taken 805 times.
✓ Branch 1 taken 103 times.
✓ Branch 2 taken 397 times.
✓ Branch 3 taken 408 times.
✓ Branch 4 taken 252 times.
✓ Branch 5 taken 145 times.
908 if(ret < 0 && (flycnt||flycnt2))
16945 660 return 0;
16946
16947 248 return ret;
16948 908 }
16949
16950 1024 esPatra::esPatra(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
16951 512 {
16952 //cs=8;
16953 512 item_set=0;
16954 512 misc=clk;
16955 512 clk4 = 0;
16956 512 clk5 = 0;
16957 512 clk = -((misc*21)>>1)-1;
16958
3/6
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 512 times.
✓ Branch 4 taken 512 times.
✗ Branch 5 not taken.
512 yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
16959 512 hit_width=12;
16960 512 hit_height=12;
16961 512 hxofs=2;
16962 512 hyofs=2;
16963 512 extend = 0;
16964 512 txsz = 1;
16965 512 tysz = 1;
16966 /* //These need to be separate enemy editor fields. This enemy class also its draw altered to correctly support big stuff.
16967 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
16968 int32_t prntSIZEflags = prntenemy->SIZEflags;
16969 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
16970 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
16971 // al_trace("Enemy txsz:%i\n", txsz);
16972 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
16973 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hxsz >= 0 ) hxsz = prntenemy->hxsz;
16974 else
16975 hxsz=12;
16976 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hysz >= 0 ) hysz = prntenemy->hysz;
16977 else
16978 hysz=12;
16979 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
16980 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
16981 else
16982 hxofs=2;
16983 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
16984 else hyofs=2;
16985 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
16986 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
16987 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
16988 {
16989 yofs = (int32_t)prntenemy->yofs; //This seems to be setting to +48 or something with any value set?! -Z
16990 }
16991
16992 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)prntenemy->zofs;
16993 */
16994 512 mainguy=count_enemy=false;
16995 512 bgsfx=-1;
16996 //o_tile=0;
16997 512 flags &= (~guy_neverret);
16998 512 deadsfx = WAV_EDEAD;
16999 512 hitsfx = WAV_EHIT;
17000 512 isCore = false;
17001 512 }
17002
17003 372279 bool esPatra::animate(int32_t index)
17004 {
17005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 372279 times.
372279 if(switch_hooked) return enemy::animate(index);
17006
2/2
✓ Branch 0 taken 7866 times.
✓ Branch 1 taken 364413 times.
372279 if(dying)
17007 7866 return Dead(index);
17008
17009 364413 return enemy::animate(index);
17010 372279 }
17011
17012 747310 void esPatra::draw(BITMAP *dest)
17013 {
17014
2/2
✓ Branch 0 taken 544720 times.
✓ Branch 1 taken 202590 times.
747310 if(get_qr(qr_NEWENEMYTILES))
17015 {
17016 544720 tile = o_tile+(clk&3);
17017
17018
8/9
✓ Branch 0 taken 67770 times.
✓ Branch 1 taken 69066 times.
✓ Branch 2 taken 67800 times.
✓ Branch 3 taken 67996 times.
✓ Branch 4 taken 67484 times.
✓ Branch 5 taken 68044 times.
✓ Branch 6 taken 68474 times.
✓ Branch 7 taken 68086 times.
✗ Branch 8 not taken.
544720 switch(dir) //directions get screwed up after 8. *shrug*
17019 {
17020 case up: //u
17021 67770 flip=0;
17022 67770 break;
17023
17024 case down: //d
17025 69066 flip=0;
17026 69066 tile+=4;
17027 69066 break;
17028
17029 case left: //l
17030 67800 flip=0;
17031 67800 tile+=8;
17032 67800 break;
17033
17034 case right: //r
17035 67996 flip=0;
17036 67996 tile+=12;
17037 67996 break;
17038
17039 case l_up: //ul
17040 67484 flip=0;
17041 67484 tile+=20;
17042 67484 break;
17043
17044 case r_up: //ur
17045 68044 flip=0;
17046 68044 tile+=24;
17047 68044 break;
17048
17049 case l_down: //dl
17050 68474 flip=0;
17051 68474 tile+=28;
17052 68474 break;
17053
17054 case r_down: //dr
17055 68086 flip=0;
17056 68086 tile+=32;
17057 68086 break;
17058 }
17059 544720 }
17060 else
17061 {
17062 202590 tile = o_tile+((clk&2)>>1);
17063 }
17064
17065
2/2
✓ Branch 0 taken 38248 times.
✓ Branch 1 taken 709062 times.
747310 if(clk>=0)
17066 709062 enemy::draw(dest);
17067 747310 }
17068
17069
17070 3 ePatraBS::ePatraBS(zfix ,zfix ,int32_t Id,int32_t Clk) : enemy((zfix)128,(zfix)48,Id,Clk)
17071 3 {
17072 3 adjusted=false;
17073
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 dir=(zc_oldrand()&7)+8;
17074
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 step=0.25;
17075 3 clk4 = 0;
17076 3 clk5 = 0;
17077 //flycnt=6; flycnt2=0;
17078 3 flycnt=dmisc1;
17079 3 flycnt2=0; // PatraBS doesn't have inner rings!
17080 3 loopcnt=0;
17081
17082 3 SIZEflags = d->SIZEflags;
17083
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = d->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17084 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17085 // al_trace("Enemy txsz:%i\n", txsz);
17086
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = d->tysz; if ( tysz > 1 ) extend = 3; }
17087
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = d->hxsz;
17088 3 else hit_width = 32;
17089
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = d->hysz;
17090
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( ((SIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = d->hzsz;
17091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = d->hxofs;
17092 3 else hxofs=-8;
17093
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = d->hyofs;
17094 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17095
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)d->xofs;
17096
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17097 {
17098 yofs = (int32_t)d->yofs; //This seems to be setting to +48 or something with any value set?! -Z
17099 yofs += (get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset) ; //this offset fixes yofs not plaing properly. -Z
17100 }
17101
17102
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3 if ( (SIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) zofs = (int32_t)d->zofs;
17103
17104
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(dmisc6<int16_t(1))dmisc6=1; // ratio cannot be 0!
17105
17106 //nets+4480;
17107 3 }
17108
17109 1862 bool ePatraBS::animate(int32_t index)
17110 {
17111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1862 times.
1862 if(switch_hooked) return enemy::animate(index);
17112
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 1808 times.
1862 if(dying)
17113 54 return Dead(index);
17114
17115
2/2
✓ Branch 0 taken 1366 times.
✓ Branch 1 taken 442 times.
1808 if(clk==0)
17116 {
17117 442 removearmos(x,y,ffcactivated);
17118 442 }
17119
17120 1808 variable_walk_8(rate,homing,hrate,spw_floater);
17121
17122
2/2
✓ Branch 0 taken 1789 times.
✓ Branch 1 taken 19 times.
1808 if(++clk2>90)
17123 {
17124 19 clk2=0;
17125
17126
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 7 times.
19 if(loopcnt)
17127 12 --loopcnt;
17128 else
17129 {
17130
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if((misc%dmisc6)==0)
17131 4 loopcnt=dmisc7;
17132 }
17133
17134 19 ++misc;
17135 19 }
17136
17137 // double size=1;;
17138
2/2
✓ Branch 0 taken 4455 times.
✓ Branch 1 taken 1808 times.
6263 for(int32_t i=index+1; i<index+flycnt+1; i++)
17139 {
17140
2/2
✓ Branch 0 taken 4437 times.
✓ Branch 1 taken 18 times.
4455 if(!adjusted)
17141 {
17142 18 ((enemy*)guys.spr(i))->hp=dmisc3;
17143
17144
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(get_qr(qr_NEWENEMYTILES))
17145 {
17146 18 ((enemy*)guys.spr(i))->o_tile=o_tile+dmisc8;
17147 18 }
17148 else
17149 {
17150 ((enemy*)guys.spr(i))->o_tile=o_tile+1;
17151 }
17152
17153 18 ((enemy*)guys.spr(i))->cs = dmisc9;
17154 18 }
17155
17156
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 4437 times.
4455 if(((enemy*)guys.spr(i))->hp <= 0)
17157 {
17158
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 18 times.
44 for(int32_t j=i; j<index+flycnt+flycnt2; j++)
17159 {
17160 26 guys.swap(j,j+1);
17161 26 }
17162
17163 18 --flycnt;
17164 18 }
17165 else
17166 {
17167 4437 int32_t pos2 = ((enemy*)guys.spr(i))->misc;
17168
1/2
✓ Branch 0 taken 4437 times.
✗ Branch 1 not taken.
4437 double a2 = ((int64_t)clk2-pos2*90/(dmisc1==0?1:dmisc1))*PI/45;
17169 4437 temp_x = zc::math::Cos(a2+PI/2)*45;
17170 4437 temp_y = -zc::math::Sin(a2+PI/2)*45;
17171
17172
2/2
✓ Branch 0 taken 2305 times.
✓ Branch 1 taken 2132 times.
4437 if(loopcnt>0)
17173 {
17174 2305 guys.spr(i)->x = zc::math::Cos(a2+PI/2)*45;
17175
1/2
✓ Branch 0 taken 2305 times.
✗ Branch 1 not taken.
2305 guys.spr(i)->y = (-zc::math::Sin(a2+PI/2)-zc::math::Cos(pos2*PI*2/(dmisc1==0?1:dmisc1)))*22.5;
17176 2305 }
17177 else
17178 {
17179 2132 guys.spr(i)->x = temp_x;
17180 2132 guys.spr(i)->y = temp_y;
17181 }
17182
17183 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17184 4437 double ddir=atan2_MSVC2022_FIX(double(temp_y),double(temp_x));
17185
17186
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 3576 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 551 times.
4437 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17187 {
17188 551 guys.spr(i)->dir=l_down;
17189 551 }
17190
4/4
✓ Branch 0 taken 844 times.
✓ Branch 1 taken 3042 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 534 times.
3886 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17191 {
17192 534 guys.spr(i)->dir=left;
17193 534 }
17194
4/4
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 2520 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 522 times.
3352 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17195 {
17196 522 guys.spr(i)->dir=l_up;
17197 522 }
17198
4/4
✓ Branch 0 taken 874 times.
✓ Branch 1 taken 1956 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 564 times.
2830 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17199 {
17200 564 guys.spr(i)->dir=up;
17201 564 }
17202
4/4
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1411 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 545 times.
2266 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17203 {
17204 545 guys.spr(i)->dir=r_up;
17205 545 }
17206
4/4
✓ Branch 0 taken 872 times.
✓ Branch 1 taken 849 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 562 times.
1721 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17207 {
17208 562 guys.spr(i)->dir=right;
17209 562 }
17210
4/4
✓ Branch 0 taken 864 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 554 times.
1159 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17211 {
17212 554 guys.spr(i)->dir=r_down;
17213 554 }
17214 else
17215 {
17216 605 guys.spr(i)->dir=down;
17217 }
17218
17219 4437 guys.spr(i)->x += x;
17220 4437 guys.spr(i)->y += y;
17221 }
17222 4455 }
17223
17224 1808 adjusted=true;
17225 1808 return enemy::animate(index);
17226 1862 }
17227
17228 3724 void ePatraBS::draw(BITMAP *dest)
17229 {
17230 3724 tile=o_tile;
17231
17232
1/2
✓ Branch 0 taken 3724 times.
✗ Branch 1 not taken.
3724 if(get_qr(qr_NEWENEMYTILES))
17233 {
17234 double _MSVC2022_tmp1, _MSVC2022_tmp2;
17235 3724 double ddir=atan2_MSVC2022_FIX(double(y-(Hero.y)),double(Hero.x-x));
17236
17237
4/4
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 3320 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 102 times.
3724 if((ddir<=(((-5)*PI)/8))&&(ddir>(((-7)*PI)/8)))
17238 {
17239 102 lookat=l_down;
17240 102 }
17241
4/4
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 3010 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 310 times.
3622 else if((ddir<=(((-3)*PI)/8))&&(ddir>(((-5)*PI)/8)))
17242 {
17243 310 lookat=down;
17244 310 }
17245
4/4
✓ Branch 0 taken 1254 times.
✓ Branch 1 taken 2058 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 952 times.
3312 else if((ddir<=(((-1)*PI)/8))&&(ddir>(((-3)*PI)/8)))
17246 {
17247 952 lookat=r_down;
17248 952 }
17249
4/4
✓ Branch 0 taken 1988 times.
✓ Branch 1 taken 372 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 1686 times.
2360 else if((ddir<=(((1)*PI)/8))&&(ddir>(((-1)*PI)/8)))
17250 {
17251 1686 lookat=right;
17252 1686 }
17253
4/4
✓ Branch 0 taken 482 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✓ Branch 3 taken 180 times.
674 else if((ddir<=(((3)*PI)/8))&&(ddir>(((1)*PI)/8)))
17254 {
17255 180 lookat=r_up;
17256 180 }
17257
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✓ Branch 2 taken 302 times.
✗ Branch 3 not taken.
494 else if((ddir<=(((5)*PI)/8))&&(ddir>(((3)*PI)/8)))
17258 {
17259 lookat=up;
17260 }
17261
3/4
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 302 times.
494 else if((ddir<=(((7)*PI)/8))&&(ddir>(((5)*PI)/8)))
17262 {
17263 lookat=l_up;
17264 }
17265 else
17266 {
17267 494 lookat=left;
17268 }
17269
17270
6/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 494 times.
✓ Branch 4 taken 1686 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 180 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 952 times.
3724 switch(lookat) //directions get screwed up after 8. *shrug*
17271 {
17272 case up: //u
17273 flip=0;
17274 break;
17275
17276 case down: //d
17277 310 flip=0;
17278 310 tile+=8;
17279 310 break;
17280
17281 case left: //l
17282 494 flip=0;
17283 494 tile+=40;
17284 494 break;
17285
17286 case right: //r
17287 1686 flip=0;
17288 1686 tile+=48;
17289 1686 break;
17290
17291 case l_up: //ul
17292 flip=0;
17293 tile+=80;
17294 break;
17295
17296 case r_up: //ur
17297 180 flip=0;
17298 180 tile+=88;
17299 180 break;
17300
17301 case l_down: //dl
17302 102 flip=0;
17303 102 tile+=120;
17304 102 break;
17305
17306 case r_down: //dr
17307 952 flip=0;
17308 952 tile+=128;
17309 952 break;
17310 }
17311
17312 3724 tile+=(2*(clk&3));
17313 3724 xofs-=8;
17314 3724 yofs-=8;
17315 3724 drawblock(dest,15);
17316 3724 xofs+=8;
17317 3724 yofs+=8;
17318 3724 }
17319 else
17320 {
17321 flip=(clk&1);
17322 xofs-=8;
17323 yofs-=8;
17324 enemy::draw(dest);
17325 xofs+=16;
17326 enemy::draw(dest);
17327 yofs+=16;
17328 enemy::draw(dest);
17329 xofs-=16;
17330 enemy::draw(dest);
17331 xofs+=8;
17332 yofs-=8;
17333 }
17334 3724 }
17335
17336 int32_t ePatraBS::defend(int32_t wpnId, int32_t *power, int32_t edef)
17337 {
17338 int32_t ret = enemy::defend(wpnId, power, edef);
17339
17340 if(ret < 0 && (flycnt||flycnt2))
17341 return 0;
17342
17343 return ret;
17344 }
17345
17346 25 int32_t ePatraBS::defendNew(int32_t wpnId, int32_t *power, int32_t edef, byte unblockable)
17347 {
17348 25 int32_t ret = enemy::defendNew(wpnId, power, edef, unblockable);
17349
17350
4/6
✓ Branch 0 taken 25 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 19 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
25 if(ret < 0 && (flycnt||flycnt2))
17351 19 return 0;
17352
17353 6 return ret;
17354 25 }
17355
17356 36 esPatraBS::esPatraBS(zfix X,zfix Y,int32_t Id,int32_t Clk, sprite * prnt) : enemy(X,Y,Id,Clk), parent(prnt)
17357 18 {
17358 //cs=csBOSS;
17359 18 item_set=0;
17360 18 misc=clk;
17361 18 clk = -((misc*21)>>1)-1;
17362 18 clk4 = 0;
17363 18 clk5 = 0;
17364
2/4
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
18 enemy *prntenemy = (enemy *) guys.getByUID(parent->getUID());
17365 18 int32_t prntSIZEflags = prntenemy->SIZEflags;
17366
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_WIDTH) != 0) && txsz > 0 ) { txsz = prntenemy->txsz; if ( txsz > 1 ) extend = 3; } //! Don;t forget to set extend if the tilesize is > 1.
17367 //al_trace("->txsz:%i\n", txsz); Verified that this is setting the value. -Z
17368 // al_trace("Enemy txsz:%i\n", txsz);
17369
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_TILE_HEIGHT) != 0) && tysz > 0 ) { tysz = prntenemy->tysz; if ( tysz > 1 ) extend = 3; }
17370
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_WIDTH) != 0) && hit_width >= 0 ) hit_width = prntenemy->hit_width;
17371 18 else hit_width=16;
17372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_HEIGHT) != 0) && hit_height >= 0 ) hit_height = prntenemy->hit_height;
17373 18 else hit_height=16;
17374
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( ((prntSIZEflags&guyflagOVERRIDE_HIT_Z_HEIGHT) != 0) && hzsz >= 0 ) hzsz = prntenemy->hzsz;
17375
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_X_OFFSET) != 0 ) hxofs = prntenemy->hxofs;
17376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_HIT_Y_OFFSET) != 0 ) hyofs = prntenemy->hyofs;
17377 18 else hyofs=2;
17378 // if ( (SIZEflags&guyflagOVERRIDEHITZOFFSET) != 0 ) hzofs = hzofs;
17379
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_X_OFFSET) != 0 ) xofs = (int32_t)prntenemy->xofs;
17380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Y_OFFSET) != 0 )
17381 {
17382 yofs = (int32_t)prntenemy->yofs;
17383 }
17384
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
18 else yofs=(get_qr(qr_OLD_DRAWOFFSET)?playing_field_offset:original_playing_field_offset);
17385
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
18 if ( (prntSIZEflags&guyflagOVERRIDE_DRAW_Z_OFFSET) != 0 ) prntenemy->zofs = (int32_t)zofs;
17386
17387 18 bgsfx=-1;
17388 18 mainguy=count_enemy=false;
17389 18 deadsfx = WAV_EDEAD;
17390 18 hitsfx = WAV_EHIT;
17391 18 flags &= ~guy_neverret;
17392 18 isCore = false;
17393 18 }
17394
17395 4790 bool esPatraBS::animate(int32_t index)
17396 {
17397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4790 times.
4790 if(switch_hooked) return enemy::animate(index);
17398
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 4466 times.
4790 if(dying)
17399 324 return Dead(index);
17400
17401 4466 return enemy::animate(index);
17402 4790 }
17403
17404 9580 void esPatraBS::draw(BITMAP *dest)
17405 {
17406 9580 tile=o_tile;
17407
17408
1/2
✓ Branch 0 taken 9580 times.
✗ Branch 1 not taken.
9580 if(get_qr(qr_NEWENEMYTILES))
17409 {
17410
8/9
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 1326 times.
✓ Branch 2 taken 1076 times.
✓ Branch 3 taken 1254 times.
✓ Branch 4 taken 1080 times.
✓ Branch 5 taken 1238 times.
✓ Branch 6 taken 1146 times.
✓ Branch 7 taken 1180 times.
✗ Branch 8 not taken.
9580 switch(dir) //directions get screwed up after 8. *shrug*
17411 {
17412 case up: //u
17413 1280 flip=0;
17414 1280 break;
17415
17416 case down: //d
17417 1326 flip=0;
17418 1326 tile+=4;
17419 1326 break;
17420
17421 case left: //l
17422 1076 flip=0;
17423 1076 tile+=8;
17424 1076 break;
17425
17426 case right: //r
17427 1254 flip=0;
17428 1254 tile+=12;
17429 1254 break;
17430
17431 case l_up: //ul
17432 1080 flip=0;
17433 1080 tile+=20;
17434 1080 break;
17435
17436 case r_up: //ur
17437 1238 flip=0;
17438 1238 tile+=24;
17439 1238 break;
17440
17441 case l_down: //dl
17442 1146 flip=0;
17443 1146 tile+=28;
17444 1146 break;
17445
17446 case r_down: //dr
17447 1180 flip=0;
17448 1180 tile+=32;
17449 1180 break;
17450 }
17451
17452 9580 tile += ((clk&6)>>1);
17453 9580 }
17454 else
17455 {
17456 tile += (clk&4)?1:0;
17457 }
17458
17459
2/2
✓ Branch 0 taken 972 times.
✓ Branch 1 taken 8608 times.
9580 if(clk>=0)
17460 8608 enemy::draw(dest);
17461 9580 }
17462
17463
17464 /**********************************/
17465 /********** Misc Code ***********/
17466 /**********************************/
17467
17468 162470 void addEwpn(int32_t x,int32_t y,int32_t z,int32_t id,int32_t type,int32_t power,int32_t dir, int32_t parentid, byte script_generated, int32_t fakez)
17469 {
17470
4/6
✓ Branch 0 taken 122104 times.
✓ Branch 1 taken 40366 times.
✓ Branch 2 taken 122104 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 122104 times.
✗ Branch 5 not taken.
162470 if(id>wEnemyWeapons || (id >= wScript1 && id <= wScript10))
17471
4/8
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 162470 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162470 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 162470 times.
✗ Branch 7 not taken.
162470 Ewpns.add(new weapon((zfix)x,(zfix)y,(zfix)z,id,type,power,dir, -1, parentid, script_generated));
17472
1/2
✓ Branch 0 taken 162470 times.
✗ Branch 1 not taken.
162470 if (fakez > 0) ((weapon*)(Ewpns.spr(Ewpns.Count()-1)))->fakez = fakez;
17473 162470 }
17474
17475 36428 int32_t hit_enemy(int32_t index, int32_t wpnId,int32_t power,int32_t wpnx,int32_t wpny,int32_t dir, int32_t enemyHitWeapon, weapon* realweap)
17476 {
17477 // Kludge
17478
4/8
✓ Branch 0 taken 36428 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36428 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36428 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 36428 times.
✗ Branch 7 not taken.
36428 weapon *w = new weapon((zfix)wpnx,(zfix)wpny,(zfix)0,wpnId,0,power,dir,enemyHitWeapon,-1,false);
17479 36428 int32_t ret = ((enemy*)guys.spr(index))->takehit(w,realweap);
17480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36428 times.
36428 delete w;
17481 36428 return ret;
17482 }
17483
17484 4228 void enemy_scored(int32_t index)
17485 {
17486 4228 ((enemy*)guys.spr(index))->scored=true;
17487 4228 }
17488
17489 1440 void addguy(int32_t x,int32_t y,int32_t id,int32_t clk,bool mainguy,mapscr* parentscr)
17490 {
17491
7/12
✓ Branch 0 taken 1440 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1440 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1440 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 115 times.
✓ Branch 9 taken 1325 times.
✓ Branch 10 taken 1440 times.
✗ Branch 11 not taken.
1440 guy *g = new guy((zfix)x,(zfix)(y+(isdungeon()?1:0)),id,get_qr(qr_NOGUYPOOF)?0:clk,mainguy);
17492
3/6
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 672 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1440 if(parentscr && parentscr->guytile > -1 && !get_qr(qr_OLD_GUY_HANDLING))
17493 {
17494 g->o_tile = parentscr->guytile;
17495 if(g->o_tile != 0)
17496 g->flags &= ~guy_invisible;
17497 g->cs = parentscr->guycs;
17498 }
17499 1440 guys.add(g);
17500 1440 }
17501
17502 22137 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17503 {
17504
5/10
✓ Branch 0 taken 22137 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22137 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22137 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 22137 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 22137 times.
✗ Branch 9 not taken.
22137 item *i = new item(zfix(x), zfix(y - get_qr(qr_NOITEMOFFSET)), 0_zf, id, pickup, 0);
17505 22137 items.add(i);
17506 22137 }
17507
17508 80 void additem(int32_t x,int32_t y,int32_t id,int32_t pickup,int32_t clk)
17509 {
17510
6/12
✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 80 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 80 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 80 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 80 times.
✗ Branch 11 not taken.
80 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,clk);
17511 80 items.add(i);
17512 80 }
17513
17514 void adddummyitem(int32_t x,int32_t y,int32_t id,int32_t pickup)
17515 {
17516 item *i = new item((zfix)x,(zfix)y-(get_qr(qr_NOITEMOFFSET)),(zfix)0,id,pickup,0,true);
17517 items.add(i);
17518 }
17519
17520 79 void kill_em_all()
17521 {
17522
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 79 times.
375 for(int32_t i=0; i<guys.Count(); i++)
17523 {
17524 296 enemy *e = ((enemy*)guys.spr(i));
17525
17526
3/6
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 271 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 25 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
296 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17527
17528 271 e->kickbucket();
17529 271 }
17530 79 }
17531
17532 bool can_kill_em_all()
17533 {
17534 for(int32_t i=0; i<guys.Count(); i++)
17535 {
17536 enemy *e = ((enemy*)guys.spr(i));
17537
17538 if(e->flags&(1<<3) && !(e->family == eeGHINI && e->dmisc1 == 1)) continue;
17539 if(e->superman) continue;
17540 return true;
17541 }
17542 return false;
17543 }
17544
17545 //This needs a quest rule, or enemy flag, Dying Enemy Doesn't Hurt Hero
17546 // For Hero's hit detection. Don't count them if they are stunned or are guys.
17547 int32_t GuyHit(int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17548 {
17549 for(int32_t i=0; i<guys.Count(); i++)
17550 {
17551 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17552 {
17553 if(((enemy*)guys.spr(i))->stunclk==0 && ((enemy*)guys.spr(i))->frozenclock==0 && (!get_qr(qr_SAFEENEMYFADE) || ((enemy*)guys.spr(i))->fading != fade_flicker)
17554 &&(((enemy*)guys.spr(i))->d->family != eeGUY || ((enemy*)guys.spr(i))->dmisc1))
17555 {
17556 return i;
17557 }
17558 }
17559 }
17560
17561 return -1;
17562 }
17563
17564 6673933 int32_t GuyHitFrom(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17565 {
17566
4/4
✓ Branch 0 taken 8694 times.
✓ Branch 1 taken 6665239 times.
✓ Branch 2 taken 19149455 times.
✓ Branch 3 taken 6656649 times.
25806104 for(int32_t i=zc_max(0, index); i<guys.Count(); i++)
17567 {
17568
2/2
✓ Branch 0 taken 17284 times.
✓ Branch 1 taken 19132171 times.
19149455 if(guys.spr(i)->hit(tx,ty,tz,txsz,tysz,tzsz))
17569 {
17570 17284 return i;
17571 }
17572 19132171 }
17573
17574 6656649 return -1;
17575 6673933 }
17576
17577 // For Hero's hit detection. Count them if they are dying.
17578 27398 int32_t GuyHit(int32_t index,int32_t tx,int32_t ty,int32_t tz,int32_t txsz,int32_t tysz,int32_t tzsz)
17579 {
17580 27398 enemy *e = (enemy*)guys.spr(index);
17581
3/4
✓ Branch 0 taken 27398 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14844 times.
✓ Branch 3 taken 12554 times.
27398 if(!e || e->hp > 0)
17582 14844 return -1;
17583
17584 12554 bool d = e->dying;
17585 12554 int32_t hc = e->hclk;
17586 12554 e->dying = false;
17587 12554 e->hclk = 0;
17588 12554 bool hit = e->hit(tx,ty,tz,txsz,tysz,tzsz);
17589 12554 e->dying = d;
17590 12554 e->hclk = hc;
17591
17592
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 12433 times.
12554 return hit ? index : -1;
17593 27398 }
17594
17595 7287092 bool hasMainGuy()
17596 {
17597
2/2
✓ Branch 0 taken 8741411 times.
✓ Branch 1 taken 2590630 times.
11332041 for(int32_t i=0; i<guys.Count(); i++)
17598 {
17599
2/2
✓ Branch 0 taken 4696462 times.
✓ Branch 1 taken 4044949 times.
8741411 if(((enemy*)guys.spr(i))->mainguy)
17600 {
17601 4696462 return true;
17602 }
17603 4044949 }
17604
17605 2590630 return false;
17606 7287092 }
17607
17608 51 void EatHero(int32_t index)
17609 {
17610 51 ((eStalfos*)guys.spr(index))->eathero();
17611 51 }
17612
17613 3 void GrabHero(int32_t index)
17614 {
17615 3 ((eWallM*)guys.spr(index))->grabhero();
17616 3 }
17617
17618 292 bool CarryHero()
17619 {
17620
1/2
✓ Branch 0 taken 891 times.
✗ Branch 1 not taken.
891 for(int32_t i=0; i<guys.Count(); i++)
17621 {
17622
2/2
✓ Branch 0 taken 536 times.
✓ Branch 1 taken 355 times.
891 if(((guy*)(guys.spr(i)))->family==eeWALLM)
17623 {
17624
2/2
✓ Branch 0 taken 292 times.
✓ Branch 1 taken 63 times.
355 if(((eWallM*)guys.spr(i))->hashero)
17625 {
17626 292 Hero.x=guys.spr(i)->x;
17627 292 Hero.y=guys.spr(i)->y;
17628 292 return ((eWallM*)guys.spr(i))->misc > 0;
17629 }
17630 63 }
17631
17632 // Like Likes currently can't carry Hero.
17633 /*
17634 if(((guy*)(guys.spr(i)))->family==eeLIKE)
17635 {
17636 if(((eLikeLike*)guys.spr(i))->hashero)
17637 {
17638 Hero.x=guys.spr(i)->x;
17639 Hero.y=guys.spr(i)->y;
17640 return (true);
17641 }
17642 }*/
17643 599 }
17644
17645 return false;
17646 292 }
17647
17648 // Move item with guy
17649 void movefairy(zfix &x,zfix &y,int32_t misc)
17650 {
17651 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17652
17653 if(i!=-1)
17654 {
17655 x = guys.spr(i)->x;
17656 y = guys.spr(i)->y;
17657 }
17658 }
17659
17660 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17661 void movefairy2(zfix x,zfix y,int32_t misc)
17662 {
17663 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17664
17665 if(i!=-1)
17666 {
17667 guys.spr(i)->x = x;
17668 guys.spr(i)->y = y;
17669 }
17670 }// Move item with guy
17671
17672 33988 void movefairynew(zfix &x,zfix &y, item const &itemfairy)
17673 {
17674 33988 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17675
17676
1/2
✓ Branch 0 taken 33988 times.
✗ Branch 1 not taken.
33988 if(fairy)
17677 {
17678 33988 x = fairy->x;
17679 33988 y = fairy->y;
17680 33988 }
17681 33988 }
17682
17683 // Move guy with item (used by FFC scripts and hookshot-dragged fairies)
17684 void movefairynew2(zfix x,zfix y, item const &itemfairy)
17685 {
17686 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17687
17688 if(fairy)
17689 {
17690 fairy->x = x;
17691 fairy->y = y;
17692 }
17693 }
17694
17695 void killfairy(int32_t misc)
17696 {
17697 int32_t i = guys.idFirst(eITEMFAIRY+0x1000*misc);
17698 guys.del(i);
17699 }
17700
17701 int32_t getGuyIndex(const int32_t eid)
17702 {
17703 for(word i = 0; i < guys.Count(); i++)
17704 {
17705 if(guys.spr(i)->getUID() == eid)
17706 return i;
17707 }
17708
17709 return -1;
17710 }
17711
17712 void killfairynew(item const &itemfairy)
17713 {
17714 enemy *fairy = (enemy *) guys.getByUID(itemfairy.fairyUID);
17715 if (fairy != NULL) guys.del(getGuyIndex(itemfairy.fairyUID));
17716 }
17717
17718 //Should probably change this to return an 'enemy*', null on failure -Em
17719 13284 int32_t addenemy(int32_t x,int32_t y,int32_t id,int32_t clk)
17720 {
17721 13284 return addenemy(x,y,0,id,clk);
17722 }
17723
17724 868 int32_t addchild(int32_t x,int32_t y,int32_t id,int32_t clk, int32_t parent_scriptUID)
17725 {
17726 868 return addchild(x,y,0,id,clk, parent_scriptUID);
17727 }
17728
17729 893 int32_t addchild(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk, int32_t parent_scriptUID)
17730 {
17731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
893 if(id <= 0) return 0;
17732
17733 893 int32_t ret = 0;
17734 893 sprite *e=NULL;
17735 893 al_trace("Adding child\n");
17736
17737
5/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 857 times.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✓ Branch 27 taken 4 times.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
893 switch(guysbuf[id&0xFFF].family)
17738 {
17739 //Fixme: possible enemy memory leak. (minor)
17740 case eeWALK:
17741
3/6
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
16 e = new eStalfos((zfix)x,(zfix)y,id,clk);
17742 16 break;
17743
17744 case eeLEV:
17745 e = new eLeever((zfix)x,(zfix)y,id,clk);
17746 break;
17747
17748 case eeTEK:
17749 e = new eTektite((zfix)x,(zfix)y,id,clk);
17750 break;
17751
17752 case eePEAHAT:
17753 e = new ePeahat((zfix)x,(zfix)y,id,clk);
17754 break;
17755
17756 case eeZORA:
17757 e = new eZora((zfix)x,(zfix)y,id,clk);
17758 break;
17759
17760 case eeGHINI:
17761 e = new eGhini((zfix)x,(zfix)y,id,clk);
17762 break;
17763
17764 case eeKEESE:
17765
3/6
✓ Branch 0 taken 857 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 857 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 857 times.
✗ Branch 5 not taken.
857 e = new eKeese((zfix)x,(zfix)y,id,clk);
17766 857 break;
17767
17768 case eeWIZZ:
17769
3/6
✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
15 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
17770 15 break;
17771
17772 case eePROJECTILE:
17773 e = new eProjectile((zfix)x,(zfix)y,id,clk);
17774 break;
17775
17776 case eeWALLM:
17777 e = new eWallM((zfix)x,(zfix)y,id,clk);
17778 break;
17779
17780 case eeAQUA:
17781 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
17782 break;
17783
17784 case eeMOLD:
17785 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17786 break;
17787
17788 case eeMANHAN:
17789
3/6
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
1 e = new eManhandla((zfix)x,(zfix)y,id,clk);
17790 1 break;
17791
17792 case eeGLEEOK:
17793 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
17794 break;
17795
17796 case eeGHOMA:
17797 e = new eGohma((zfix)x,(zfix)y,id,clk);
17798 break;
17799
17800 case eeLANM:
17801 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
17802 break;
17803
17804 case eeGANON:
17805 e = new eGanon((zfix)x,(zfix)y,id,clk);
17806 break;
17807
17808 case eeFAIRY:
17809 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
17810 break;
17811
17812 case eeFIRE:
17813 e = new eFire((zfix)x,(zfix)y,id,clk);
17814 break;
17815
17816 case eeOTHER:
17817 e = new eOther((zfix)x,(zfix)y,id,clk);
17818 break;
17819
17820
17821 case eeSCRIPT01:
17822 case eeSCRIPT02:
17823 case eeSCRIPT03:
17824 case eeSCRIPT04:
17825 case eeSCRIPT05:
17826 case eeSCRIPT06:
17827 case eeSCRIPT07:
17828 case eeSCRIPT08:
17829 case eeSCRIPT09:
17830 case eeSCRIPT10:
17831 case eeSCRIPT11:
17832 case eeSCRIPT12:
17833 case eeSCRIPT13:
17834 case eeSCRIPT14:
17835 case eeSCRIPT15:
17836 case eeSCRIPT16:
17837 case eeSCRIPT17:
17838 case eeSCRIPT18:
17839 case eeSCRIPT19:
17840 case eeSCRIPT20:
17841 {
17842 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17843 {
17844 e = new eScript((zfix)x,(zfix)y,id,clk);
17845 break;
17846 }
17847 else return 0;
17848 }
17849
17850 case eeFFRIENDLY01:
17851 case eeFFRIENDLY02:
17852 case eeFFRIENDLY03:
17853 case eeFFRIENDLY04:
17854 case eeFFRIENDLY05:
17855 case eeFFRIENDLY06:
17856 case eeFFRIENDLY07:
17857 case eeFFRIENDLY08:
17858 case eeFFRIENDLY09:
17859 case eeFFRIENDLY10:
17860 {
17861 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
17862 {
17863 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
17864 }
17865 else return 0;
17866
17867 }
17868
17869 case eeSPINTILE:
17870 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
17871 break;
17872
17873 // and these enemies use the misc10/misc2 value
17874 case eeROCK:
17875 {
17876 switch(guysbuf[id&0xFFF].misc10)
17877 {
17878 case 1:
17879 e = new eBoulder((zfix)x,(zfix)y,id,clk);
17880 break;
17881
17882 case 0:
17883 default:
17884 e = new eRock((zfix)x,(zfix)y,id,clk);
17885 break;
17886 }
17887
17888 break;
17889 }
17890
17891 case eeTRAP:
17892 {
17893 switch(guysbuf[id&0xFFF].misc2)
17894 {
17895 case 1:
17896 e = new eTrap2((zfix)x,(zfix)y,id,clk);
17897 break;
17898
17899 case 0:
17900 default:
17901 e = new eTrap((zfix)x,(zfix)y,id,clk);
17902 break;
17903 }
17904
17905 break;
17906 }
17907
17908 case eeDONGO:
17909 {
17910 switch(guysbuf[id&0xFFF].misc10)
17911 {
17912 case 1:
17913 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
17914 break;
17915
17916 case 0:
17917 default:
17918 e = new eDodongo((zfix)x,(zfix)y,id,clk);
17919 break;
17920 }
17921
17922 break;
17923 }
17924
17925 case eeDIG:
17926 {
17927
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 switch(guysbuf[id&0xFFF].misc10)
17928 {
17929 case 1:
17930 e = new eLilDig((zfix)x,(zfix)y,id,clk);
17931 break;
17932
17933 4 case 0:
17934 default:
17935
3/6
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 e = new eBigDig((zfix)x,(zfix)y,id,clk);
17936 4 break;
17937 }
17938
17939 4 break;
17940 }
17941
17942 case eePATRA:
17943 {
17944 switch(guysbuf[id&0xFFF].misc10)
17945 {
17946 case 1:
17947 if (get_qr(qr_HARDCODED_BS_PATRA))
17948 {
17949 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
17950 break;
17951 }
17952 [[fallthrough]];
17953 case 0:
17954 default:
17955 e = new ePatra((zfix)x,(zfix)y,id,clk);
17956 break;
17957 }
17958
17959 break;
17960 }
17961
17962 case eeGUY:
17963 {
17964 switch(guysbuf[id&0xFFF].misc10)
17965 {
17966 case 1:
17967 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17968 break;
17969
17970 case 0:
17971 default:
17972 e = new eNPC((zfix)x,(zfix)y,id,clk);
17973 break;
17974 }
17975
17976 break;
17977 }
17978
17979 case eeNONE:
17980 if(guysbuf[id&0xFFF].misc10 ==1)
17981 {
17982 e = new eTrigger((zfix)x,(zfix)y,id,clk);
17983 break;
17984 break;
17985 }
17986 [[fallthrough]];
17987 default:
17988
17989 return 0;
17990 }
17991
17992 893 ret++; // Made one enemy.
17993
17994
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 893 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
893 if(z && canfall(id))
17995 {
17996 e->z = (zfix)z;
17997 }
17998
17999
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 ((enemy*)e)->ceiling = (z && canfall(id));
18000 893 ((enemy*)e)->parent_script_UID = parent_scriptUID;
18001 //al_trace("Child Script UID: %d\n",((enemy*)e)->script_UID);
18002 //zprint2("Child Script UID: %d\n",((enemy*)e)->script_UID);
18003 //al_trace("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18004 //zprint2("Child's Parent UID: %d\n",((enemy*)e)->parent_script_UID);
18005
18006
18007
1/2
✓ Branch 0 taken 893 times.
✗ Branch 1 not taken.
893 if(!guys.add(e))
18008 {
18009 return 0;
18010 }
18011
18012 // add segments of segmented enemies
18013 893 int32_t c=0;
18014
18015
2/6
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
893 switch(guysbuf[id&0xFFF].family)
18016 {
18017 case eeMOLD:
18018 {
18019 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18020 id &= 0xFFF;
18021
18022 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18023 {
18024 //christ this is messy -DD
18025 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18026
18027 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18028 {
18029 al_trace("Moldorm segment %d could not be created!\n",i+1);
18030
18031 for(int32_t j=0; j<i+1; j++)
18032 guys.del(guys.Count()-1);
18033
18034 return 0;
18035 }
18036
18037 if(i>0)
18038 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18039
18040 ret++;
18041 }
18042
18043 break;
18044 }
18045
18046 case eeLANM:
18047 {
18048 id &= 0xFFF;
18049 int32_t shft = guysbuf[id].misc2;
18050 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18051
18052 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18053 {
18054 al_trace("Lanmola segment 1 could not be created!\n");
18055 guys.del(guys.Count()-1);
18056 return 0;
18057 }
18058
18059 ret++;
18060
18061 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18062 {
18063 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18064 {
18065 al_trace("Lanmola segment %d could not be created!\n",i+1);
18066
18067 for(int32_t j=0; j<i+1; j++)
18068 guys.del(guys.Count()-1);
18069
18070 return 0;
18071 }
18072
18073 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18074 ret++;
18075 }
18076 }
18077 break;
18078
18079 case eeMANHAN:
18080 1 id &= 0xFFF;
18081
18082
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
5 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18083 {
18084
4/8
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
4 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18085 {
18086 al_trace("Manhandla head %d could not be created!\n",i+1);
18087
18088 for(int32_t j=0; j<i+1; j++)
18089 {
18090 guys.del(guys.Count()-1);
18091 }
18092
18093 return 0;
18094 }
18095
18096 4 ret++;
18097 4 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18098 4 }
18099
18100 1 break;
18101
18102 case eeGLEEOK:
18103 {
18104 id &= 0xFFF;
18105
18106 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18107 {
18108 if(!guys.add(new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e)))
18109 {
18110 al_trace("Gleeok head %d could not be created!\n",i+1);
18111
18112 for(int32_t j=0; j<i+1; j++)
18113 {
18114 guys.del(guys.Count()-1);
18115 }
18116
18117 return false;
18118 }
18119
18120 c-=guysbuf[id].misc4;
18121 ret++;
18122 }
18123 }
18124 break;
18125
18126
18127 case eePATRA:
18128 {
18129 id &= 0xFFF;
18130 int32_t outeyes = 0;
18131
18132 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18133 {
18134 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18135 {
18136 al_trace("Patra outer eye %d could not be created!\n",i+1);
18137
18138 for(int32_t j=0; j<i+1; j++)
18139 guys.del(guys.Count()-1);
18140
18141 return 0;
18142 }
18143 else
18144 outeyes++;
18145
18146 ret++;
18147 }
18148
18149 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18150 {
18151 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18152 {
18153 al_trace("Patra inner eye %d could not be created!\n",i+1);
18154
18155 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18156 guys.del(guys.Count()-1);
18157
18158 return 0;
18159 }
18160
18161 ret++;
18162 }
18163
18164 break;
18165 }
18166 }
18167
18168 893 return ret;
18169 893 }
18170
18171 // Returns number of enemies/segments created
18172 52936 int32_t addenemy(int32_t x,int32_t y,int32_t z,int32_t id,int32_t clk)
18173 {
18174 //zprint2("addenemy id is: %d\n", (id&0xFFF));
18175 52936 int32_t realid = id&0xFFF;
18176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if( realid > MAXGUYS )
18177 {
18178 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "addenemy()");
18179 return 0;
18180 }
18181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52936 times.
52936 if(id <= 0) return 0;
18182
18183 52936 int32_t ret = 0;
18184 52936 sprite *e=NULL;
18185
18186
27/31
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 26744 times.
✓ Branch 4 taken 1694 times.
✓ Branch 5 taken 2941 times.
✓ Branch 6 taken 1048 times.
✓ Branch 7 taken 1605 times.
✓ Branch 8 taken 140 times.
✓ Branch 9 taken 5764 times.
✓ Branch 10 taken 2135 times.
✓ Branch 11 taken 2257 times.
✓ Branch 12 taken 523 times.
✓ Branch 13 taken 76 times.
✓ Branch 14 taken 94 times.
✓ Branch 15 taken 58 times.
✓ Branch 16 taken 94 times.
✓ Branch 17 taken 55 times.
✓ Branch 18 taken 239 times.
✓ Branch 19 taken 10 times.
✓ Branch 20 taken 413 times.
✓ Branch 21 taken 374 times.
✓ Branch 22 taken 4900 times.
✓ Branch 23 taken 94 times.
✓ Branch 24 taken 256 times.
✓ Branch 25 taken 889 times.
✓ Branch 26 taken 141 times.
✓ Branch 27 taken 246 times.
✓ Branch 28 taken 56 times.
✗ Branch 29 not taken.
✓ Branch 30 taken 90 times.
52936 switch(guysbuf[id&0xFFF].family)
18187 {
18188 //Fixme: possible enemy memory leak. (minor)
18189 case eeWALK:
18190
3/6
✓ Branch 0 taken 26744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26744 times.
✗ Branch 5 not taken.
26744 e = new eStalfos((zfix)x,(zfix)y,id,clk);
18191 26744 break;
18192
18193 case eeLEV:
18194
3/6
✓ Branch 0 taken 1694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1694 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1694 times.
✗ Branch 5 not taken.
1694 e = new eLeever((zfix)x,(zfix)y,id,clk);
18195 1694 break;
18196
18197 case eeTEK:
18198
3/6
✓ Branch 0 taken 2941 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2941 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2941 times.
✗ Branch 5 not taken.
2941 e = new eTektite((zfix)x,(zfix)y,id,clk);
18199 2941 break;
18200
18201 case eePEAHAT:
18202
3/6
✓ Branch 0 taken 1048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1048 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1048 times.
✗ Branch 5 not taken.
1048 e = new ePeahat((zfix)x,(zfix)y,id,clk);
18203 1048 break;
18204
18205 case eeZORA:
18206
3/6
✓ Branch 0 taken 1605 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1605 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1605 times.
✗ Branch 5 not taken.
1605 e = new eZora((zfix)x,(zfix)y,id,clk);
18207 1605 break;
18208
18209 case eeGHINI:
18210
3/6
✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 140 times.
✗ Branch 5 not taken.
140 e = new eGhini((zfix)x,(zfix)y,id,clk);
18211 140 break;
18212
18213 case eeKEESE:
18214
3/6
✓ Branch 0 taken 5764 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5764 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5764 times.
✗ Branch 5 not taken.
5764 e = new eKeese((zfix)x,(zfix)y,id,clk);
18215 5764 break;
18216
18217 case eeWIZZ:
18218
3/6
✓ Branch 0 taken 2135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2135 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2135 times.
✗ Branch 5 not taken.
2135 e = new eWizzrobe((zfix)x,(zfix)y,id,clk);
18219 2135 break;
18220
18221 case eePROJECTILE:
18222
3/6
✓ Branch 0 taken 2257 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2257 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2257 times.
✗ Branch 5 not taken.
2257 e = new eProjectile((zfix)x,(zfix)y,id,clk);
18223 2257 break;
18224
18225 case eeWALLM:
18226
3/6
✓ Branch 0 taken 523 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 523 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 523 times.
✗ Branch 5 not taken.
523 e = new eWallM((zfix)x,(zfix)y,id,clk);
18227 523 break;
18228
18229 case eeAQUA:
18230
3/6
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 76 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 76 times.
✗ Branch 5 not taken.
76 e = new eAquamentus((zfix)x,(zfix)y,id,clk);
18231 76 break;
18232
18233 case eeMOLD:
18234
6/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 94 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 94 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eMoldorm((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18235 94 break;
18236
18237 case eeMANHAN:
18238
3/6
✓ Branch 0 taken 58 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58 times.
✗ Branch 5 not taken.
58 e = new eManhandla((zfix)x,(zfix)y,id,clk);
18239 58 break;
18240
18241 case eeGLEEOK:
18242
7/12
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 94 times.
✓ Branch 6 taken 79 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 79 times.
✓ Branch 10 taken 94 times.
✗ Branch 11 not taken.
94 e = new eGleeok((zfix)x,(zfix)y,id,zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)));
18243 94 break;
18244
18245 case eeGHOMA:
18246
3/6
✓ Branch 0 taken 55 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 55 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 55 times.
✗ Branch 5 not taken.
55 e = new eGohma((zfix)x,(zfix)y,id,clk);
18247 55 break;
18248
18249 case eeLANM:
18250
6/12
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 239 times.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 239 times.
✓ Branch 10 taken 239 times.
✗ Branch 11 not taken.
239 e = new eLanmola((zfix)x,(zfix)y,id,zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)));
18251 239 break;
18252
18253 case eeGANON:
18254
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✗ Branch 5 not taken.
10 e = new eGanon((zfix)x,(zfix)y,id,clk);
18255 10 break;
18256
18257 case eeFAIRY:
18258
3/6
✓ Branch 0 taken 413 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 413 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 413 times.
✗ Branch 5 not taken.
413 e = new eItemFairy((zfix)x,(zfix)y,id+0x1000*clk,clk);
18259 413 break;
18260
18261 case eeFIRE:
18262
3/6
✓ Branch 0 taken 374 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 374 times.
✗ Branch 5 not taken.
374 e = new eFire((zfix)x,(zfix)y,id,clk);
18263 374 break;
18264
18265 case eeOTHER:
18266
3/6
✓ Branch 0 taken 4900 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4900 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4900 times.
✗ Branch 5 not taken.
4900 e = new eOther((zfix)x,(zfix)y,id,clk);
18267 4900 break;
18268
18269
18270 case eeSCRIPT01:
18271 case eeSCRIPT02:
18272 case eeSCRIPT03:
18273 case eeSCRIPT04:
18274 case eeSCRIPT05:
18275 case eeSCRIPT06:
18276 case eeSCRIPT07:
18277 case eeSCRIPT08:
18278 case eeSCRIPT09:
18279 case eeSCRIPT10:
18280 case eeSCRIPT11:
18281 case eeSCRIPT12:
18282 case eeSCRIPT13:
18283 case eeSCRIPT14:
18284 case eeSCRIPT15:
18285 case eeSCRIPT16:
18286 case eeSCRIPT17:
18287 case eeSCRIPT18:
18288 case eeSCRIPT19:
18289 case eeSCRIPT20:
18290 {
18291 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18292 {
18293 e = new eScript((zfix)x,(zfix)y,id,clk);
18294 break;
18295 }
18296 else return 0;
18297 }
18298
18299 case eeFFRIENDLY01:
18300 case eeFFRIENDLY02:
18301 case eeFFRIENDLY03:
18302 case eeFFRIENDLY04:
18303 case eeFFRIENDLY05:
18304 case eeFFRIENDLY06:
18305 case eeFFRIENDLY07:
18306 case eeFFRIENDLY08:
18307 case eeFFRIENDLY09:
18308 case eeFFRIENDLY10:
18309 {
18310 if ( !get_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES) )
18311 {
18312 e = new eFriendly((zfix)x,(zfix)y,id,clk); break;
18313 }
18314 else return 0;
18315
18316 }
18317
18318 case eeSPINTILE:
18319
3/6
✓ Branch 0 taken 94 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 94 times.
✗ Branch 5 not taken.
94 e = new eSpinTile((zfix)x,(zfix)y,id,clk);
18320 94 break;
18321
18322 // and these enemies use the misc10/misc2 value
18323 case eeROCK:
18324 {
18325
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 226 times.
256 switch(guysbuf[id&0xFFF].misc10)
18326 {
18327 case 1:
18328
3/6
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 30 times.
✗ Branch 5 not taken.
30 e = new eBoulder((zfix)x,(zfix)y,id,clk);
18329 30 break;
18330
18331 226 case 0:
18332 default:
18333
3/6
✓ Branch 0 taken 226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 226 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 226 times.
✗ Branch 5 not taken.
226 e = new eRock((zfix)x,(zfix)y,id,clk);
18334 226 break;
18335 }
18336
18337 256 break;
18338 }
18339
18340 case eeTRAP:
18341 {
18342
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 147 times.
✓ Branch 2 taken 742 times.
889 switch(guysbuf[id&0xFFF].misc2)
18343 {
18344 case 1:
18345
3/6
✓ Branch 0 taken 147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 147 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 147 times.
✗ Branch 5 not taken.
147 e = new eTrap2((zfix)x,(zfix)y,id,clk);
18346 147 break;
18347
18348 742 case 0:
18349 default:
18350
3/6
✓ Branch 0 taken 742 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 742 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 742 times.
✗ Branch 5 not taken.
742 e = new eTrap((zfix)x,(zfix)y,id,clk);
18351 742 break;
18352 }
18353
18354 889 break;
18355 }
18356
18357 case eeDONGO:
18358 {
18359
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 139 times.
141 switch(guysbuf[id&0xFFF].misc10)
18360 {
18361 case 1:
18362
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 e = new eDodongo2((zfix)x,(zfix)y,id,clk);
18363 2 break;
18364
18365 139 case 0:
18366 default:
18367
3/6
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
139 e = new eDodongo((zfix)x,(zfix)y,id,clk);
18368 139 break;
18369 }
18370
18371 141 break;
18372 }
18373
18374 case eeDIG:
18375 {
18376
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 198 times.
✓ Branch 2 taken 48 times.
246 switch(guysbuf[id&0xFFF].misc10)
18377 {
18378 case 1:
18379
3/6
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 198 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 198 times.
✗ Branch 5 not taken.
198 e = new eLilDig((zfix)x,(zfix)y,id,clk);
18380 198 break;
18381
18382 48 case 0:
18383 default:
18384
3/6
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
48 e = new eBigDig((zfix)x,(zfix)y,id,clk);
18385 48 break;
18386 }
18387
18388 246 break;
18389 }
18390
18391 case eePATRA:
18392 {
18393
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 3 times.
56 switch(guysbuf[id&0xFFF].misc10)
18394 {
18395 case 1:
18396
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (get_qr(qr_HARDCODED_BS_PATRA))
18397 {
18398
3/6
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
3 e = new ePatraBS((zfix)x,(zfix)y,id,clk);
18399 3 break;
18400 }
18401 [[fallthrough]];
18402 53 case 0:
18403 default:
18404
3/6
✓ Branch 0 taken 53 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 53 times.
✗ Branch 5 not taken.
53 e = new ePatra((zfix)x,(zfix)y,id,clk);
18405 53 break;
18406 }
18407
18408 56 break;
18409 }
18410
18411 case eeGUY:
18412 {
18413 switch(guysbuf[id&0xFFF].misc10)
18414 {
18415 case 1:
18416 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18417 break;
18418
18419 case 0:
18420 default:
18421 e = new eNPC((zfix)x,(zfix)y,id,clk);
18422 break;
18423 }
18424
18425 break;
18426 }
18427
18428 case eeNONE:
18429
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 if(guysbuf[id&0xFFF].misc10 ==1)
18430 {
18431
3/6
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90 times.
✗ Branch 5 not taken.
90 e = new eTrigger((zfix)x,(zfix)y,id,clk);
18432 90 break;
18433 break;
18434 }
18435 [[fallthrough]];
18436 default:
18437
18438 return 0;
18439 }
18440
18441 52936 ret++; // Made one enemy.
18442
18443
4/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 52853 times.
✓ Branch 2 taken 24 times.
✓ Branch 3 taken 59 times.
52936 if(z && canfall(id))
18444 {
18445 59 e->z = (zfix)z;
18446 59 }
18447
18448
2/2
✓ Branch 0 taken 52853 times.
✓ Branch 1 taken 83 times.
52936 ((enemy*)e)->ceiling = (z && canfall(id));
18449
18450
1/2
✓ Branch 0 taken 52936 times.
✗ Branch 1 not taken.
52936 if(!guys.add(e))
18451 {
18452 return 0;
18453 }
18454
18455 // add segments of segmented enemies
18456 52936 int32_t c=0;
18457
18458
6/6
✓ Branch 0 taken 52395 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 239 times.
✓ Branch 3 taken 58 times.
✓ Branch 4 taken 94 times.
✓ Branch 5 taken 56 times.
52936 switch(guysbuf[id&0xFFF].family)
18459 {
18460 case eeMOLD:
18461 {
18462 94 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18463 94 id &= 0xFFF;
18464
18465
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 624 times.
✓ Branch 2 taken 624 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 624 times.
✓ Branch 6 taken 530 times.
✓ Branch 7 taken 94 times.
624 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id].misc1)); i++)
18466 {
18467 //christ this is messy -DD
18468 530 int32_t segclk = -i*((int32_t)(8.0/(zslongToFix(guysbuf[id&0xFFF].step*100))));
18469
18470
4/8
✓ Branch 0 taken 530 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 530 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 530 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 530 times.
✗ Branch 7 not taken.
530 if(!guys.add(new esMoldorm((zfix)x,(zfix)y,id+0x1000,segclk)))
18471 {
18472 al_trace("Moldorm segment %d could not be created!\n",i+1);
18473
18474 for(int32_t j=0; j<i+1; j++)
18475 guys.del(guys.Count()-1);
18476
18477 return 0;
18478 }
18479
18480
2/2
✓ Branch 0 taken 94 times.
✓ Branch 1 taken 436 times.
530 if(i>0)
18481 436 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18482
18483 530 ret++;
18484 530 }
18485
18486 94 break;
18487 }
18488
18489 case eeLANM:
18490 {
18491 239 id &= 0xFFF;
18492 239 int32_t shft = guysbuf[id].misc2;
18493 239 byte is=((enemy*)guys.spr(guys.Count()-1))->item_set;
18494
18495
4/8
✓ Branch 0 taken 239 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 239 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 239 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 239 times.
✗ Branch 7 not taken.
239 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x1000,0)))
18496 {
18497 al_trace("Lanmola segment 1 could not be created!\n");
18498 guys.del(guys.Count()-1);
18499 return 0;
18500 }
18501
18502 239 ret++;
18503
18504
5/8
✗ Branch 0 not taken.
✓ Branch 1 taken 1250 times.
✓ Branch 2 taken 1250 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 1250 times.
✓ Branch 6 taken 1011 times.
✓ Branch 7 taken 239 times.
1250 for(int32_t i=1; i<zc_max(1,zc_min(253,guysbuf[id&0xFFF].misc1)); i++)
18505 {
18506
4/8
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1011 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1011 times.
✗ Branch 7 not taken.
1011 if(!guys.add(new esLanmola((zfix)x,(zfix)y,id+0x2000,-(i<<shft))))
18507 {
18508 al_trace("Lanmola segment %d could not be created!\n",i+1);
18509
18510 for(int32_t j=0; j<i+1; j++)
18511 guys.del(guys.Count()-1);
18512
18513 return 0;
18514 }
18515
18516 1011 ((enemy*)guys.spr(guys.Count()-1))->item_set=is;
18517 1011 ret++;
18518 1011 }
18519 }
18520 239 break;
18521
18522 case eeMANHAN:
18523 58 id &= 0xFFF;
18524
18525
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 58 times.
322 for(int32_t i=0; i<((!(guysbuf[id].misc2))?4:8); i++)
18526 {
18527
4/8
✓ Branch 0 taken 264 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 264 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 264 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 264 times.
✗ Branch 7 not taken.
264 if(!guys.add(new esManhandla((zfix)x,(zfix)y,id+0x1000,i)))
18528 {
18529 al_trace("Manhandla head %d could not be created!\n",i+1);
18530
18531 for(int32_t j=0; j<i+1; j++)
18532 {
18533 guys.del(guys.Count()-1);
18534 }
18535
18536 return 0;
18537 }
18538
18539 264 ret++;
18540 264 ((enemy*)guys.spr(guys.Count()-1))->frate=guysbuf[id].misc1;
18541 264 }
18542
18543 58 break;
18544
18545 case eeGLEEOK:
18546 {
18547 94 id &= 0xFFF;
18548 94 eGleeok* parent = (eGleeok*)e;
18549
18550
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 362 times.
✓ Branch 2 taken 332 times.
✓ Branch 3 taken 30 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 332 times.
✓ Branch 6 taken 268 times.
✓ Branch 7 taken 94 times.
362 for(int32_t i=0; i<zc_max(1,zc_min(254,guysbuf[id&0xFFF].misc1)); i++)
18551 {
18552
3/6
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 268 times.
✗ Branch 5 not taken.
268 esGleeok* head = new esGleeok((zfix)x,(zfix)y,id+0x1000,c, e);
18553
1/2
✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
268 if(!guys.add(head))
18554 {
18555 al_trace("Gleeok head %d could not be created!\n",i+1);
18556
18557 for(int32_t j=0; j<i+1; j++)
18558 {
18559 guys.del(guys.Count()-1);
18560 }
18561
18562 return false;
18563 }
18564
18565 268 head->necktile=parent->necktile;
18566 268 head->dummy_int[1]=parent->necktile;
18567
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 73 times.
268 if(get_qr(qr_NEWENEMYTILES))
18568 {
18569 195 head->dummy_int[2]=parent->o_tile+parent->dmisc8; //connected head tile
18570 195 head->dummy_int[3]=parent->o_tile+parent->dmisc9; //flying head tile
18571 195 }
18572 else
18573 {
18574 73 head->dummy_int[2]=parent->necktile+1; //connected head tile
18575 73 head->dummy_int[3]=parent->necktile+2; //flying head tile
18576 }
18577 268 head->tile = head->dummy_int[2];
18578
18579 268 c-=guysbuf[id].misc4;
18580 268 ret++;
18581 268 }
18582 }
18583 94 break;
18584
18585
18586 case eePATRA:
18587 {
18588 56 id &= 0xFFF;
18589 56 int32_t outeyes = 0;
18590
18591
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 498 times.
✓ Branch 2 taken 442 times.
✓ Branch 3 taken 56 times.
498 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc1); i++)
18592 {
18593
10/22
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 424 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 424 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 424 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 424 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
442 if(!((guysbuf[id].misc10&&get_qr(qr_HARDCODED_BS_PATRA))?guys.add(new esPatraBS((zfix)x,(zfix)y,id+0x1000,i,e)):guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e))))
18594 {
18595 al_trace("Patra outer eye %d could not be created!\n",i+1);
18596
18597 for(int32_t j=0; j<i+1; j++)
18598 guys.del(guys.Count()-1);
18599
18600 return 0;
18601 }
18602 else
18603 442 outeyes++;
18604
18605 442 ret++;
18606 442 }
18607
18608
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
✓ Branch 2 taken 88 times.
✓ Branch 3 taken 56 times.
144 for(int32_t i=0; i<zc_min(254,guysbuf[id&0xFFF].misc2); i++)
18609 {
18610
4/8
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 88 times.
✗ Branch 7 not taken.
88 if(!guys.add(new esPatra((zfix)x,(zfix)y,id+0x1000,i,e)))
18611 {
18612 al_trace("Patra inner eye %d could not be created!\n",i+1);
18613
18614 for(int32_t j=0; j<i+1+zc_min(254,outeyes); j++)
18615 guys.del(guys.Count()-1);
18616
18617 return 0;
18618 }
18619
18620 88 ret++;
18621 88 }
18622
18623 56 break;
18624 }
18625 }
18626
18627 52936 return ret;
18628 52936 }
18629
18630 1251618 bool isjumper(int32_t id)
18631 {
18632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1251618 times.
1251618 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18633 {
18634 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isjumper()");
18635 return false;
18636 }
18637
3/3
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1151282 times.
✓ Branch 2 taken 100332 times.
1251618 switch(guysbuf[id&0xFFF].family)
18638 {
18639 case eeROCK:
18640 case eeTEK:
18641 4 return true;
18642
18643 case eeWALK:
18644
3/4
✓ Branch 0 taken 100332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12265 times.
✓ Branch 3 taken 88067 times.
100332 if(guysbuf[id&0xFFF].misc9==e9tVIRE || guysbuf[id&0xFFF].misc9==e9tPOLSVOICE) return true;
18645 88067 }
18646
18647 1239349 return false;
18648 1251618 }
18649
18650
18651 115481 bool isfixedtogrid(int32_t id)
18652 {
18653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115481 times.
115481 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18654 {
18655 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isfixedtogrid()");
18656 return false;
18657 }
18658
1/2
✓ Branch 0 taken 115481 times.
✗ Branch 1 not taken.
115481 switch(guysbuf[id&0xFFF].family)
18659 {
18660 case eeWALK:
18661 case eeLEV:
18662 case eeZORA:
18663 case eeDONGO:
18664 case eeGANON:
18665 case eeROCK:
18666 case eeGLEEOK:
18667 case eeAQUA:
18668 case eeLANM:
18669 return true;
18670 }
18671
18672 115481 return false;
18673 115481 }
18674
18675 // Can't fall, can have Z value.
18676 30363108 bool isflier(int32_t id)
18677 {
18678
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30363108 times.
30363108 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18679 {
18680 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "isflier()");
18681 return false;
18682 }
18683
2/2
✓ Branch 0 taken 27055941 times.
✓ Branch 1 taken 3307167 times.
30363108 switch(guysbuf[id&0xFFF].family) //id&0x0FFF)
18684 {
18685 case eePEAHAT:
18686 case eeKEESE:
18687 case eePATRA:
18688 case eeFAIRY:
18689 case eeGHINI:
18690
18691 // Could theoretically have their Z set by a script
18692 case eeFIRE:
18693 3307167 return true;
18694 break;
18695 }
18696
18697 27055941 return false;
18698 30363108 }
18699
18700 // Can't have Z position
18701 2341162 bool never_in_air(int32_t id)
18702 {
18703
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2341162 times.
2341162 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18704 {
18705 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "never_in_air()");
18706 return false;
18707 }
18708
2/2
✓ Branch 0 taken 2331614 times.
✓ Branch 1 taken 9548 times.
2341162 switch(guysbuf[id&0xFFF].family)
18709 {
18710 case eeMANHAN:
18711 case eeMOLD:
18712 case eeLANM:
18713 case eeGLEEOK:
18714 case eeZORA:
18715 case eeLEV:
18716 case eeAQUA:
18717 case eeROCK:
18718 case eeGANON:
18719 case eeTRAP:
18720 case eePROJECTILE:
18721 case eeSPINTILE:
18722 9548 return true;
18723 }
18724
18725 2331614 return false;
18726 2341162 }
18727
18728 1370668 bool canfall(int32_t id)
18729 {
18730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1370668 times.
1370668 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18731 {
18732 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "canfall()");
18733 return false;
18734 }
18735
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 1370642 times.
✓ Branch 2 taken 26 times.
1370668 switch(guysbuf[id&0xFFF].family)
18736 {
18737 case eeGUY:
18738 {
18739
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(id < eOCTO1S)
18740 26 return false;
18741
18742 switch(guysbuf[id&0xFFF].misc10)
18743 {
18744 case 1:
18745 case 2:
18746 return true;
18747
18748 case 0:
18749 case 3:
18750 default:
18751 return false;
18752 }
18753
18754 case eeGHOMA:
18755 case eeDIG:
18756 return false;
18757 }
18758 }
18759
18760
18761
4/4
✓ Branch 0 taken 1362208 times.
✓ Branch 1 taken 8434 times.
✓ Branch 2 taken 110590 times.
✓ Branch 3 taken 1251618 times.
1370642 return !never_in_air(id) && !isflier(id) && !isjumper(id);
18762 1370668 }
18763
18764 31454090 bool enemy::enemycanfall(int32_t id, bool checkgrav)
18765 {
18766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31454090 times.
31454090 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
18767 {
18768 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "enemycanfall()");
18769 return false;
18770 }
18771 //Z_scripterrlog("canfall family is %d:\n", family);
18772 //Z_scripterrlog("canfall gravity is %s:\n", moveflags & FLAG_OBEYS_GRAV ? "true" : "false");
18773 //if ( family == eeFIRE && id >= eSTART )
18774 //{
18775 // Z_scripterrlog("eeFire\n");
18776 // return moveflags & FLAG_OBEYS_GRAV; //'Other' enemy class, used by scripts. -Z
18777 //}
18778
18779 //In ZQ, eeFIRE is Other(floating) and eeOTHER is 'other'.
18780
18781
3/3
✓ Branch 0 taken 195032 times.
✓ Branch 1 taken 30218229 times.
✓ Branch 2 taken 1040829 times.
31454090 switch(guysbuf[id&0xFFF].family)
18782 {
18783 case eeGUY:
18784 {
18785
1/2
✓ Branch 0 taken 1040829 times.
✗ Branch 1 not taken.
1040829 if(id < eOCTO1S) //screen guys and fires that aren't real enemies, and never fall
18786 1040829 return false;
18787
18788 switch(guysbuf[id&0xFFF].misc10) //I'm unsure what these specify off-hand. Needs better comments. -Z
18789 {
18790 case 1:
18791 case 2:
18792 return true;
18793
18794 case 0:
18795 case 3:
18796 default:
18797 return false;
18798 }
18799
18800 case eeGHOMA:
18801 case eeDIG:
18802 195032 return false;
18803 }
18804 }
18805
18806
2/2
✓ Branch 0 taken 21662519 times.
✓ Branch 1 taken 8555710 times.
30218229 if(!checkgrav) return true;
18807 21662519 return (moveflags & FLAG_OBEYS_GRAV);
18808
18809 // if ( isflier(id) || isjumper(id) || never_in_air(id) )
18810 // {
18811 // if ( moveflags & FLAG_OBEYS_GRAV ) return true;
18812 // else return false;
18813 // }
18814 // else
18815 // {
18816 // return (moveflags & FLAG_OBEYS_GRAV);
18817 // }
18818 //return !never_in_air(id) && !isflier(id) && !isjumper(id);
18819 31454090 }
18820
18821 758 void addfires()
18822 {
18823
2/2
✓ Branch 0 taken 422 times.
✓ Branch 1 taken 336 times.
758 if(!get_qr(qr_NOGUYFIRES))
18824 {
18825 336 int32_t bs = get_qr(qr_BSZELDA);
18826 336 addguy(bs? 64: 72,64,gFIRE,-17,false,nullptr);
18827 336 addguy(bs?176:168,64,gFIRE,-18,false,nullptr);
18828 336 }
18829 758 }
18830
18831 16276 void loadguys()
18832 {
18833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16276 times.
16276 if(loaded_guys)
18834 return;
18835
18836 16276 loaded_guys=true;
18837
18838 16276 byte Guy=0;
18839 // When in caves/item rooms, use mSPECIALITEM and ipONETIME2
18840 // Else use mITEM and ipONETIME
18841 16276 int32_t mf = (currscr>=128) ? mSPECIALITEM : mITEM;
18842 16276 int32_t onetime = (currscr>=128) ? ipONETIME2 : ipONETIME;
18843
18844 16276 repaircharge=0;
18845 16276 adjustmagic=false;
18846 16276 learnslash=false;
18847
18848
2/2
✓ Branch 0 taken 48828 times.
✓ Branch 1 taken 16276 times.
65104 for(int32_t i=0; i<3; i++)
18849 {
18850 48828 prices[i]=0;
18851 48828 }
18852
18853 16276 hasitem=0;
18854
18855 16276 mapscr* guyscr = tmpscr;
18856
4/4
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 15597 times.
✓ Branch 2 taken 340 times.
✓ Branch 3 taken 339 times.
16276 if(currscr>=128 && DMaps[currdmap].flags&dmfGUYCAVES)
18857 {
18858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339 times.
339 if(DMaps[currdmap].flags&dmfCAVES)
18859 {
18860 339 Guy=tmpscr[1].guy;
18861 339 guyscr = tmpscr+1;
18862 339 }
18863 339 }
18864 else
18865 {
18866 15937 Guy=tmpscr->guy;
18867
18868
4/4
✓ Branch 0 taken 15597 times.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 9437 times.
✓ Branch 3 taken 6160 times.
15937 if(currscr < 0x80 && (DMaps[currdmap].flags&dmfVIEWMAP))
18869 6160 game->maps[(currmap*MAPSCRSNORMAL)+currscr] |= mVISITED; // mark as visited
18870 }
18871
18872 16276 bool oldguy = get_qr(qr_OLD_GUY_HANDLING);
18873 // The Guy appears if 'Hero is in cave' equals 'Guy is in cave'.
18874
4/4
✓ Branch 0 taken 2858 times.
✓ Branch 1 taken 13418 times.
✓ Branch 2 taken 2081 times.
✓ Branch 3 taken 777 times.
16276 if(Guy && ((currscr>=128) == !!(DMaps[currdmap].flags&dmfGUYCAVES)))
18875 {
18876
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 768 times.
777 if(tmpscr->room==rZELDA)
18877 {
18878 9 addguy(120,72,Guy,-15,true,guyscr);
18879 9 guys.spr(0)->hxofs=1000;
18880 9 addenemy(128,96,eFIRE,-15);
18881 9 addenemy(112,96,eFIRE,-15);
18882 9 addenemy(96,120,eFIRE,-15);
18883 9 addenemy(144,120,eFIRE,-15);
18884 9 return;
18885 }
18886
18887
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
1536 bool ffire = oldguy
18888
2/2
✓ Branch 0 taken 758 times.
✓ Branch 1 taken 10 times.
768 ? (Guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES))
18889 : (guyscr->roomflags&RFL_GUYFIRES);
18890
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 758 times.
768 if(ffire)
18891 758 addfires();
18892
18893
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 335 times.
768 if(currscr>=128)
18894
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 323 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
347 if(getmapflag() && !(tmpscr->flags9&fBELOWRETURN))
18895 12 Guy=0;
18896
18897
4/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 647 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 23 times.
768 switch(tmpscr->room)
18898 {
18899 case rSP_ITEM:
18900 case rGRUMBLE:
18901 case rBOMBS:
18902 case rARROWS:
18903 case rSWINDLE:
18904 case rMUPGRADE:
18905 case rLEARNSLASH:
18906 case rTAKEONE:
18907
8/8
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 20 times.
✓ Branch 7 taken 33 times.
97 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18908 28 Guy=0;
18909
18910 117 break;
18911
18912 case rREPAIR:
18913 if (get_qr(qr_OLD_DOORREPAIR)) break;
18914 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18915 Guy=0;
18916
18917 break;
18918 case rRP_HC:
18919 if (get_qr(qr_OLD_POTION_OR_HC)) break;
18920 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18921 Guy=0;
18922
18923 break;
18924 case rMONEY:
18925
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (get_qr(qr_OLD_SECRETMONEY)) break;
18926 if((get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag((currscr < 128) ? mITEM : mSPECIALITEM)) || (!get_qr(qr_ITEMPICKUPSETSBELOW) && getmapflag() && !(tmpscr->flags9&fBELOWRETURN))) //get_qr(qr_ITEMPICKUPSETSBELOW)
18927 Guy=0;
18928
18929 break;
18930
18931 case rTRIFORCE:
18932 {
18933 23 int32_t tc = TriforceCount();
18934
18935
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 12 times.
23 if(get_qr(qr_4TRI))
18936 {
18937
4/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
11 if((get_qr(qr_3TRI) && tc>=3) || tc>=4)
18938 10 Guy=0;
18939 9 }
18940 else
18941 {
18942
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if((get_qr(qr_3TRI) && tc>=6) || tc>=8)
18943 12 Guy=0;
18944 }
18945 }
18946 21 break;
18947 }
18948
18949
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 708 times.
766 if(Guy)
18950 {
18951
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 698 times.
708 if(ffire)
18952 698 blockpath=true;
18953
18954
2/2
✓ Branch 0 taken 323 times.
✓ Branch 1 taken 385 times.
708 if(currscr<128)
18955 385 sfx(WAV_SCALE);
18956
18957
4/4
✓ Branch 0 taken 326 times.
✓ Branch 1 taken 382 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 323 times.
708 addguy(120,64,Guy, (dlevel||BSZ)?-15:startguy[zc_oldrand()&7], true,guyscr);
18958 708 Hero.Freeze();
18959 708 }
18960 766 }
18961
3/6
✓ Branch 0 taken 15499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 51 times.
✓ Branch 3 taken 15448 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
15499 else if(oldguy ? Guy==gFAIRY : (Guy && (guyscr->roomflags&RFL_ALWAYS_GUY))) // The only Guy that somewhat ignores the "Guys In Caves Only" DMap flag
18962 {
18963 51 sfx(WAV_SCALE);
18964 51 addguy(120,62,Guy,-14,false,guyscr);
18965 51 }
18966
18967 16265 loaditem();
18968
18969 // Collecting a rupee in a '10 Rupees' screen sets the mITEM screen state if
18970 // it doesn't appear in a Cave/Item Cellar, and the mSPECIALITEM screen state if it does.
18971
4/4
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16255 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 8 times.
16265 if(tmpscr->room==r10RUPIES && !getmapflag(mf))
18972 {
18973 //setmapflag();
18974
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 8 times.
88 for(int32_t i=0; i<10; i++)
18975 80 additem(ten_rupies_x[i],ten_rupies_y[i],0,ipBIGRANGE+onetime,-14);
18976 8 }
18977 16274 }
18978
18979 16281 void loaditem()
18980 {
18981 16281 byte Item = 0;
18982
18983
2/2
✓ Branch 0 taken 15602 times.
✓ Branch 1 taken 679 times.
16281 if(currscr<128)
18984 {
18985 15602 Item=tmpscr->item;
18986
18987
4/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 14804 times.
✓ Branch 2 taken 14227 times.
✓ Branch 3 taken 1375 times.
15602 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
18988 {
18989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1375 times.
1375 if(tmpscr->flags8&fSECRETITEM)
18990 hasitem=8;
18991
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 746 times.
1375 else if(tmpscr->flags&fITEM)
18992 629 hasitem=1;
18993
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 712 times.
746 else if(tmpscr->enemyflags&efCARRYITEM)
18994 34 hasitem=4; // Will be set to 2 by roaming_item
18995 else
18996
2/4
✓ Branch 0 taken 712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 712 times.
✗ Branch 3 not taken.
1424 items.add(new item((zfix)tmpscr->itemx,
18997
7/14
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 712 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 712 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 712 times.
✗ Branch 13 not taken.
712 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
18998
6/10
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 709 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 709 times.
✗ Branch 9 not taken.
712 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
18999
2/2
✓ Branch 0 taken 62 times.
✓ Branch 1 taken 650 times.
712 Item,ipONETIME|ipBIGRANGE|((itemsbuf[Item].family==itype_triforcepiece ||
19000 712 (tmpscr->flags3&fHOLDITEM)) ? ipHOLDUP : 0) | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19001 1375 }
19002 15602 }
19003
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 else if(!(DMaps[currdmap].flags&dmfCAVES))
19004 {
19005
4/6
✓ Branch 0 taken 340 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 336 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 times.
341 if((!getmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM) || (tmpscr[1].flags9&fBELOWRETURN)) && tmpscr[1].room==rSP_ITEM
19006
4/4
✓ Branch 0 taken 110 times.
✓ Branch 1 taken 230 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 109 times.
340 && (currscr==128 || !get_qr(qr_ITEMSINPASSAGEWAYS)))
19007 {
19008 110 Item=tmpscr[1].catchall;
19009
19010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
110 if(Item)
19011
2/4
✓ Branch 0 taken 110 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 110 times.
✗ Branch 3 not taken.
220 items.add(new item((zfix)tmpscr->itemx,
19012
4/14
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 110 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 110 times.
✗ Branch 13 not taken.
110 (tmpscr->flags7&fITEMFALLS && isSideViewGravity()) ? (zfix)-170 : (zfix)tmpscr->itemy+(get_qr(qr_NOITEMOFFSET)?0:1),
19013
2/10
✗ Branch 0 not taken.
✓ Branch 1 taken 110 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 110 times.
✗ Branch 9 not taken.
110 (tmpscr->flags7&fITEMFALLS && !(isSideViewGravity())) ? (zfix)170 : (zfix)0,
19014 110 Item,ipONETIME2|ipBIGRANGE|ipHOLDUP | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0),0));
19015 110 }
19016 340 }
19017 16281 }
19018
19019 539 void never_return(int32_t index)
19020 {
19021
2/2
✓ Branch 0 taken 409 times.
✓ Branch 1 taken 130 times.
539 if(!get_qr(qr_KILLALL))
19022 130 goto doit;
19023
19024
2/2
✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 201 times.
1541 for(int32_t i=0; i<guys.Count(); i++)
19025
4/4
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 826 times.
✓ Branch 2 taken 208 times.
✓ Branch 3 taken 306 times.
1340 if(((((enemy*)guys.spr(i))->d->flags)&guy_neverret) && i!=index)
19026 {
19027 208 goto dontdoit;
19028 201 }
19029
19030 doit:
19031 331 setmapflag(mNEVERRET);
19032 dontdoit:
19033 539 return;
19034 }
19035
19036 36942 bool slowguy(int32_t id)
19037 {
19038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36942 times.
36942 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19039 {
19040 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "slowguy()");
19041 return false;
19042 }
19043 //return (guysbuf[id].step<100);
19044
2/2
✓ Branch 0 taken 31379 times.
✓ Branch 1 taken 5563 times.
36942 switch(id)
19045 {
19046 case eOCTO1S:
19047 case eOCTO2S:
19048 case eOCTO1F:
19049 case eOCTO2F:
19050 case eLEV1:
19051 case eLEV2:
19052 case eROCK:
19053 case eBOULDER:
19054 5563 return true;
19055 }
19056
19057 31379 return false;
19058 36942 }
19059
19060 41699 bool ok2add(int32_t id)
19061 {
19062
2/4
✓ Branch 0 taken 41699 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 41699 times.
41699 if( ((unsigned)(id&0xFFF)) > MAXGUYS || id <= 0)
19063 {
19064 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "oktoadd()");
19065 return false;
19066 }
19067
4/4
✓ Branch 0 taken 408 times.
✓ Branch 1 taken 41291 times.
✓ Branch 2 taken 190 times.
✓ Branch 3 taken 218 times.
41699 if(getmapflag(mNEVERRET) && (guysbuf[id].flags & guy_neverret))
19068 218 return false;
19069
19070
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
✓ Branch 2 taken 63 times.
✓ Branch 3 taken 92 times.
41481 switch(guysbuf[id].family)
19071 {
19072 // I added a special case for shooters because having traps on the same screen
19073 // was preventing them from spawning due to TMPNORET. This means they will
19074 // never stay dead, though, so it may not be the best solution. - Saf
19075 case eePROJECTILE:
19076 63 return true;
19077
19078
19079 case eeDIG:
19080 {
19081
2/3
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
✓ Branch 2 taken 47 times.
92 switch(guysbuf[id].misc10)
19082 {
19083 case 1:
19084
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 32 times.
45 if(!get_qr(qr_NOTMPNORET))
19085 13 return !getmapflag(mTMPNORET);
19086
19087 32 return true;
19088
19089 47 case 0:
19090 default:
19091 47 return true;
19092 }
19093 }
19094 case eeGANON:
19095 case eeTRAP:
19096 if ((guysbuf[id].family == eeGANON && !get_qr(qr_CAN_PLACE_GANON))
19097 || (guysbuf[id].family == eeTRAP && !get_qr(qr_CAN_PLACE_TRAPS))) return false;
19098 [[fallthrough]];
19099 default:
19100
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41326 times.
41326 if (guysbuf[id].flags2&guy_ignoretmpnr) return true;
19101 41326 break;
19102 }
19103
19104
2/2
✓ Branch 0 taken 14322 times.
✓ Branch 1 taken 27004 times.
41326 if(!get_qr(qr_NOTMPNORET))
19105 27004 return !getmapflag(mTMPNORET);
19106
19107 14322 return true;
19108 41699 }
19109
19110 402634 void activate_fireball_statue(int32_t pos)
19111 {
19112
3/4
✓ Branch 0 taken 113289 times.
✓ Branch 1 taken 289345 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113289 times.
402634 if(!(tmpscr->enemyflags&efFIREBALLS) || statueID<0)
19113 {
19114 289345 return;
19115 }
19116
19117 113289 int32_t cx=-1000, cy=-1000;
19118 113289 int32_t x = (pos&15)<<4;
19119 113289 int32_t y = pos&0xF0;
19120
19121 113289 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19122
19123
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113289 times.
113289 if(!isfixedtogrid(statueID))
19124 {
19125
2/2
✓ Branch 0 taken 997 times.
✓ Branch 1 taken 112292 times.
113289 if(ctype==cL_STATUE)
19126 {
19127 997 cx=x+4;
19128 997 cy=y+7;
19129 997 }
19130
2/2
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 111276 times.
112292 else if(ctype==cR_STATUE)
19131 {
19132 1016 cx=x-8;
19133 1016 cy=y-1;
19134 1016 }
19135
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 179 times.
111276 else if(ctype==cC_STATUE)
19136 {
19137 179 cx=x;
19138 179 cy=y;
19139 179 }
19140 113289 }
19141 else if(ctype==cL_STATUE || ctype==cR_STATUE || ctype==cC_STATUE)
19142 {
19143 cx=x;
19144 cy=y;
19145 }
19146
19147
2/2
✓ Branch 0 taken 111097 times.
✓ Branch 1 taken 2192 times.
113289 if(cx!=-1000) // No point creating it if this is false
19148 {
19149
2/2
✓ Branch 0 taken 6281 times.
✓ Branch 1 taken 2192 times.
8473 for(int32_t j=0; j<guys.Count(); j++)
19150 {
19151
3/4
✓ Branch 0 taken 1171 times.
✓ Branch 1 taken 5110 times.
✓ Branch 2 taken 1171 times.
✗ Branch 3 not taken.
6281 if((int32_t(guys.spr(j)->x)==cx)&&(int32_t(guys.spr(j)->y)==cy))
19152 {
19153 if((guys.spr(j)->id&0xFFF) == statueID) // There's already a matching enemy here!
19154 return; // No point deleting it. A script might be toying with it in some way.
19155 else
19156 guys.del(j);
19157 }
19158 6281 }
19159
19160 2192 addenemy(cx, cy, statueID, !isfixedtogrid(statueID) ? 24 : 0);
19161 2192 }
19162 402634 }
19163
19164 16136 void activate_fireball_statues()
19165 {
19166
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 15518 times.
16136 if(!(tmpscr->enemyflags&efFIREBALLS))
19167 {
19168 15518 return;
19169 }
19170
19171
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 108768 times.
109386 for(int32_t i=0; i<176; i++)
19172 {
19173 108768 activate_fireball_statue(i);
19174 108768 }
19175 16136 }
19176
19177 16136 void load_default_enemies()
19178 {
19179 16136 wallm_load_clk=frame-80;
19180
19181
2/2
✓ Branch 0 taken 15104 times.
✓ Branch 1 taken 1032 times.
16136 if(tmpscr->enemyflags&efZORA)
19182 {
19183
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(zoraID>=0)
19184 1032 addenemy(-16, -16, zoraID, 0);
19185 1032 }
19186
19187
2/2
✓ Branch 0 taken 16033 times.
✓ Branch 1 taken 103 times.
16136 if(tmpscr->enemyflags&efTRAP4)
19188 {
19189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(cornerTrapID>=0)
19190 {
19191 103 addenemy(32, 32, cornerTrapID, -14);
19192 103 addenemy(208, 32, cornerTrapID, -14);
19193 103 addenemy(32, 128, cornerTrapID, -14);
19194 103 addenemy(208, 128, cornerTrapID, -14);
19195 103 }
19196 103 }
19197
19198
2/2
✓ Branch 0 taken 177496 times.
✓ Branch 1 taken 16136 times.
193632 for(int32_t y=0; y<176; y+=16)
19199 {
19200
2/2
✓ Branch 0 taken 2839936 times.
✓ Branch 1 taken 177496 times.
3017432 for(int32_t x=0; x<256; x+=16)
19201 {
19202 2839936 int32_t ctype = combobuf[MAPCOMBO(x,y)].type;
19203 2839936 int32_t cflag = MAPFLAG(x, y);
19204 2839936 int32_t cflag_i = MAPCOMBOFLAG(x, y);
19205
19206
4/6
✓ Branch 0 taken 2839936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839865 times.
✓ Branch 3 taken 71 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839865 times.
2839936 if(ctype==cTRAP_H || cflag==mfTRAP_H || cflag_i==mfTRAP_H)
19207 {
19208
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 61 times.
71 if(trapLOSHorizontalID>=0)
19209 61 addenemy(x, y, trapLOSHorizontalID, -14);
19210 71 }
19211
4/6
✓ Branch 0 taken 2839865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839829 times.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839829 times.
2839865 else if(ctype==cTRAP_V || cflag==mfTRAP_V || cflag_i==mfTRAP_V)
19212 {
19213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(trapLOSVerticalID>=0)
19214 36 addenemy(x, y, trapLOSVerticalID, -14);
19215 36 }
19216
4/6
✓ Branch 0 taken 2839829 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839678 times.
✓ Branch 3 taken 151 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839678 times.
2839829 else if(ctype==cTRAP_4 || cflag==mfTRAP_4 || cflag_i==mfTRAP_4)
19217 {
19218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(trapLOS4WayID>=0)
19219 {
19220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 151 times.
151 if(addenemy(x, y, trapLOS4WayID, -14))
19221 151 guys.spr(guys.Count()-1)->dummy_int[1]=2;
19222 151 }
19223 151 }
19224
19225
4/6
✓ Branch 0 taken 2839678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839611 times.
✓ Branch 3 taken 67 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839611 times.
2839678 else if(ctype==cTRAP_LR || cflag==mfTRAP_LR || cflag_i==mfTRAP_LR)
19226 {
19227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(trapConstantHorizontalID>=0)
19228 67 addenemy(x, y, trapConstantHorizontalID, -14);
19229 67 }
19230
4/6
✓ Branch 0 taken 2839611 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2839531 times.
✓ Branch 3 taken 80 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2839531 times.
2839611 else if(ctype==cTRAP_UD || cflag==mfTRAP_UD || cflag_i==mfTRAP_UD)
19231 {
19232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
80 if(trapConstantVerticalID>=0)
19233 80 addenemy(x, y, trapConstantVerticalID, -14);
19234 80 }
19235
19236
1/2
✓ Branch 0 taken 2839936 times.
✗ Branch 1 not taken.
2839936 if(ctype==cSPINTILE1)
19237 {
19238 // Awaken spinning tile
19239 awaken_spinning_tile(tmpscr,COMBOPOS(x,y));
19240 }
19241 2839936 }
19242 177496 }
19243
19244
2/2
✓ Branch 0 taken 16093 times.
✓ Branch 1 taken 43 times.
16136 if(tmpscr->enemyflags&efTRAP2)
19245 {
19246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(centerTrapID>=-1)
19247 {
19248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(64, 80, centerTrapID, -14))
19249 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19250
19251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(addenemy(176, 80, centerTrapID, -14))
19252 43 guys.spr(guys.Count()-1)->dummy_int[1]=1;
19253 43 }
19254 43 }
19255
19256
2/2
✓ Branch 0 taken 16069 times.
✓ Branch 1 taken 67 times.
16136 if(tmpscr->enemyflags&efROCKS)
19257 {
19258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if(rockID>=0)
19259 {
19260 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19261 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19262 67 addenemy(zc_oldrand()&0xF0, 0, rockID, 0);
19263 67 }
19264 67 }
19265
19266 16136 activate_fireball_statues();
19267 16136 }
19268
19269 20300239 void update_slope_combopos(int32_t lyr, int32_t pos)
19270 {
19271
2/4
✓ Branch 0 taken 20300239 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 20300239 times.
20300239 if(unsigned(lyr) > 6 || unsigned(pos) > 175) return;
19272 20300239 mapscr* s = FFCore.tempScreens[lyr];
19273 20300239 newcombo const& cmb = combobuf[s->data[pos]];
19274
19275 20300239 auto id = (176*lyr)+pos;
19276 20300239 auto it = slopes.find(id);
19277
19278 20300239 bool wasSlope = it!=slopes.end();
19279 20300239 bool isSlope = cmb.type == cSLOPE;
19280
19281
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 20300146 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
20300239 if(isSlope && !wasSlope)
19282 {
19283 93 slopes.try_emplace(id, &(s->data[pos]), nullptr, id, pos);
19284 93 }
19285
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20300146 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20300146 else if(wasSlope && !isSlope)
19286 {
19287 slopes.erase(it);
19288 }
19289 20300239 }
19290 16291 void update_slope_comboposes()
19291 {
19292
2/2
✓ Branch 0 taken 114037 times.
✓ Branch 1 taken 16291 times.
130328 for(auto lyr = 0; lyr < 7; ++lyr)
19293 {
19294
2/2
✓ Branch 0 taken 20070512 times.
✓ Branch 1 taken 114037 times.
20184549 for(auto pos = 0; pos < 176; ++pos)
19295 20070512 update_slope_combopos(lyr,pos);
19296 114037 }
19297 16291 }
19298
19299 // Everything that must be done before we change a screen's combo to another combo, or a combo's type to another type.
19300 // There's 2 routines because it's unclear if combobuf or tmpscr->data gets modified. -L
19301 293866 void screen_combo_modify_preroutine(mapscr *s, int32_t pos)
19302 {
19303 293866 delete_fireball_shooter(s, pos);
19304 293866 }
19305
19306 //Placeholder in case we need it.
19307 void screen_ffc_modify_preroutine(word index)
19308 {
19309 return;
19310 }
19311
19312 // Everything that must be done after we change a screen's combo to another combo. -L
19313 293866 void screen_combo_modify_postroutine(mapscr *s, int32_t pos)
19314 {
19315 293866 s->valid |= mVALID;
19316 293866 activate_fireball_statue(pos);
19317
19318
2/2
✓ Branch 0 taken 293772 times.
✓ Branch 1 taken 94 times.
293866 if(combobuf[s->data[pos]].type==cSPINTILE1)
19319 {
19320 // Awaken spinning tile
19321 94 awaken_spinning_tile(s,pos);
19322 94 }
19323 293866 int32_t lyr = -1;
19324
2/2
✓ Branch 0 taken 89735 times.
✓ Branch 1 taken 204131 times.
293866 if(s == tmpscr) lyr = 0;
19325
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 479085 times.
543224 else for(size_t q = 0; q < 6; ++q)
19326 {
19327
2/2
✓ Branch 0 taken 25596 times.
✓ Branch 1 taken 453489 times.
479085 if(s == tmpscr2+q)
19328 {
19329 25596 lyr = q+1;
19330 25596 break;
19331 }
19332 453489 }
19333
2/2
✓ Branch 0 taken 64139 times.
✓ Branch 1 taken 229727 times.
293866 if(lyr > -1)
19334 229727 update_slope_combopos(lyr,pos);
19335 293866 }
19336
19337 4358129 void screen_ffc_modify_postroutine(word index)
19338 {
19339 4358129 ffcdata& ff = tmpscr->ffcs[index];
19340 4358129 newcombo const& cmb = combobuf[ff.data];
19341
19342 4358129 auto id = (176*7)+int32_t(index);
19343 4358129 auto it = slopes.find(id);
19344
19345 4358129 bool wasSlope = it!=slopes.end();
19346
1/2
✓ Branch 0 taken 4358129 times.
✗ Branch 1 not taken.
4358129 bool isSlope = cmb.type == cSLOPE && !(ff.flags&ffCHANGER);
19347
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358129 if(isSlope && !wasSlope)
19348 {
19349 slopes.try_emplace(id, nullptr, &ff, id);
19350 }
19351
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4358129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4358129 else if(wasSlope && !isSlope)
19352 {
19353 slopes.erase(it);
19354 }
19355
19356 4358129 tmpscr->ffcCountMarkDirty();
19357 4358129 }
19358
19359 4320 void screen_combo_modify_pre(int32_t cid)
19360 {
19361
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19362 {
19363 30240 mapscr* t = FFCore.tempScreens[lyr];
19364
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19365 {
19366
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19367 {
19368 4395 screen_combo_modify_preroutine(t,i);
19369 4395 }
19370 5322240 }
19371 30240 }
19372 4320 }
19373 4320 void screen_combo_modify_post(int32_t cid)
19374 {
19375
2/2
✓ Branch 0 taken 30240 times.
✓ Branch 1 taken 4320 times.
34560 for(auto lyr = 0; lyr < 7; ++lyr)
19376 {
19377 30240 mapscr* t = FFCore.tempScreens[lyr];
19378
2/2
✓ Branch 0 taken 5322240 times.
✓ Branch 1 taken 30240 times.
5352480 for(int32_t i = 0; i < 176; i++)
19379 {
19380
2/2
✓ Branch 0 taken 5317845 times.
✓ Branch 1 taken 4395 times.
5322240 if(t->data[i] == cid)
19381 {
19382 4395 screen_combo_modify_postroutine(t,i);
19383 4395 }
19384 5322240 }
19385 30240 }
19386
2/2
✓ Branch 0 taken 552960 times.
✓ Branch 1 taken 4320 times.
557280 for(word ind = 0; ind < MAXFFCS; ++ind)
19387 {
19388
1/2
✓ Branch 0 taken 552960 times.
✗ Branch 1 not taken.
552960 if(tmpscr->ffcs[ind].data == cid)
19389 screen_ffc_modify_postroutine(ind);
19390 552960 }
19391 4320 }
19392
19393 94 void awaken_spinning_tile(mapscr *s, int32_t pos)
19394 {
19395
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 94 times.
94 addenemy((pos&15)<<4,pos&0xF0,(s->cset[pos]<<12)+eSPINTILE1,combobuf[s->data[pos]].o_tile+zc_max(1,combobuf[s->data[pos]].frames));
19396 94 }
19397
19398
19399 // It stands for next_side_pos
19400 9987 void nsp(bool random)
19401 // moves sle_x and sle_y to the next position
19402 {
19403
2/2
✓ Branch 0 taken 3261 times.
✓ Branch 1 taken 6726 times.
9987 if(random)
19404 {
19405
2/2
✓ Branch 0 taken 1634 times.
✓ Branch 1 taken 1627 times.
3261 if(zc_oldrand()%2)
19406 {
19407 1634 sle_x = (zc_oldrand()%2) ? 0 : 240;
19408 1634 sle_y = (zc_oldrand()%10)*16;
19409 1634 }
19410 else
19411 {
19412 1627 sle_y = (zc_oldrand()%2) ? 0 : 160;
19413 1627 sle_x = (zc_oldrand()%15)*16;
19414 }
19415
19416 3261 return;
19417 }
19418
19419
2/2
✓ Branch 0 taken 5084 times.
✓ Branch 1 taken 1642 times.
6726 if(sle_x==0)
19420 {
19421
2/2
✓ Branch 0 taken 1496 times.
✓ Branch 1 taken 146 times.
1642 if(sle_y<160)
19422 1496 sle_y+=16;
19423 else
19424 146 sle_x+=16;
19425 1642 }
19426
2/2
✓ Branch 0 taken 2122 times.
✓ Branch 1 taken 2962 times.
5084 else if(sle_y==160)
19427 {
19428
2/2
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 137 times.
2122 if(sle_x<240)
19429 1985 sle_x+=16;
19430 else
19431 137 sle_y-=16;
19432 2122 }
19433
2/2
✓ Branch 0 taken 1288 times.
✓ Branch 1 taken 1674 times.
2962 else if(sle_x==240)
19434 {
19435
2/2
✓ Branch 0 taken 1165 times.
✓ Branch 1 taken 123 times.
1288 if(sle_y>0)
19436 1165 sle_y-=16;
19437 else
19438 123 sle_x-=16;
19439 1288 }
19440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1674 times.
1674 else if(sle_y==0)
19441 {
19442
1/2
✓ Branch 0 taken 1674 times.
✗ Branch 1 not taken.
1674 if(sle_x>0)
19443 1674 sle_x-=16;
19444 else
19445 sle_y+=16;
19446 1674 }
19447 9987 }
19448
19449 1932 int32_t next_side_pos(bool random)
19450 // moves sle_x and sle_y to the next available position
19451 // returns the direction the enemy should face
19452 {
19453 bool blocked;
19454 1932 int32_t c=0;
19455
19456 1932 do
19457 {
19458
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 9862 times.
9987 nsp(c>35 ? false : random);
19459
3/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 8056 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
11918 blocked = _walkflag(sle_x,sle_y,2) || _walkflag(sle_x,sle_y+8,2) ||
19460
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 (combo_class_buf[COMBOTYPE(sle_x,sle_y)].block_enemies ||
19461
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1931 times.
✗ Branch 3 not taken.
1931 MAPFLAG(sle_x,sle_y) == mfNOENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOENEMY ||
19462
2/4
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1931 times.
1931 MAPFLAG(sle_x,sle_y) == mfNOGROUNDENEMY || MAPCOMBOFLAG(sle_x,sle_y)==mfNOGROUNDENEMY ||
19463 1931 iswaterex(MAPCOMBO(sle_x,sle_y), currmap, currscr, -1, sle_x, sle_y, true));
19464
19465
2/2
✓ Branch 0 taken 9986 times.
✓ Branch 1 taken 1 times.
9987 if(++c>50)
19466 1 return -1;
19467
2/2
✓ Branch 0 taken 8055 times.
✓ Branch 1 taken 1931 times.
9986 }
19468 9986 while(blocked);
19469
19470 1931 int32_t dir=0;
19471
19472
2/2
✓ Branch 0 taken 1354 times.
✓ Branch 1 taken 577 times.
1931 if(sle_x==0) dir=right;
19473
19474
2/2
✓ Branch 0 taken 1430 times.
✓ Branch 1 taken 501 times.
1931 if(sle_y==0) dir=down;
19475
19476
2/2
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 542 times.
1931 if(sle_x==240) dir=left;
19477
19478
1/2
✓ Branch 0 taken 1931 times.
✗ Branch 1 not taken.
1931 if(sle_y==168) dir=up;
19479
19480 1931 return dir;
19481 1932 }
19482
19483 bool can_side_load(int32_t id)
19484 {
19485 if( ((unsigned)(id&0xFFF)) > MAXGUYS )
19486 {
19487 //zprint2("Invalid enemy ID (%d) passed to %s\n", id, "can_side_load()");
19488 return false;
19489 }
19490 switch(guysbuf[id].family) //id&0x0FFF)
19491 {
19492 //case eTEK1:
19493 //case eTEK2:
19494 //case eTEK3:
19495 //case eLEV1:
19496 //case eLEV2:
19497 //case eLEV3:
19498 //case eRAQUAM:
19499 //case eLAQUAM:
19500 //case eDODONGO:
19501 //case eMANHAN:
19502 //case eGLEEOK1:
19503 //case eGLEEOK2:
19504 //case eGLEEOK3:
19505 //case eGLEEOK4:
19506 //case eDIG1:
19507 //case eDIG3:
19508 //case eGOHMA1:
19509 //case eGOHMA2:
19510 //case eCENT1:
19511 //case eCENT2:
19512 //case ePATRA1:
19513 //case ePATRA2:
19514 //case eGANON:
19515 //case eMANHAN2:
19516 //case eCEILINGM: later
19517 //case eFLOORM: later
19518 //case ePATRABS:
19519 //case ePATRAL2:
19520 //case ePATRAL3:
19521 //case eGLEEOK1F:
19522 //case eGLEEOK2F:
19523 //case eGLEEOK3F:
19524 //case eGLEEOK4F:
19525 //case eDODONGOBS:
19526 //case eDODONGOF:
19527 //case eGOHMA3:
19528 //case eGOHMA4:
19529 //case eSHOOTMAGIC:
19530 //case eSHOOTROCK:
19531 //case eSHOOTSPEAR:
19532 //case eSHOOTSWORD:
19533 //case eSHOOTFLAME:
19534 //case eSHOOTFLAME2:
19535 //case eSHOOTFBALL:
19536 case eeTEK:
19537 case eeLEV:
19538 case eeAQUA:
19539 case eeDONGO:
19540 case eeMANHAN:
19541 case eeGLEEOK:
19542 case eeDIG:
19543 case eeGHOMA:
19544 case eeLANM:
19545 case eePATRA:
19546 case eeGANON:
19547 case eePROJECTILE:
19548 return false;
19549 break;
19550 }
19551
19552 return true;
19553 }
19554
19555 static bool script_sle = false;
19556 static int32_t sle_pattern = 0;
19557 void script_side_load_enemies()
19558 {
19559 if(script_sle || sle_clk) return;
19560 sle_cnt = 0;
19561 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19562 ++sle_cnt;
19563 script_sle = true;
19564 sle_pattern = tmpscr->pattern;
19565 sle_clk = 0;
19566 }
19567
19568 42952 void side_load_enemies()
19569 {
19570
3/4
✓ Branch 0 taken 42952 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 578 times.
42952 if(!script_sle && sle_clk==0)
19571 {
19572 578 sle_pattern = tmpscr->pattern;
19573 578 sle_cnt = 0;
19574 578 int32_t guycnt = 0;
19575 578 int16_t s = (currmap<<7)+currscr;
19576 578 bool beenhere=false;
19577 578 bool reload=true;
19578 578 bool unbeatablereload = true;
19579
19580 578 load_default_enemies();
19581
19582
2/2
✓ Branch 0 taken 3468 times.
✓ Branch 1 taken 578 times.
4046 for(int32_t i=0; i<6; i++)
19583
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 178 times.
3646 if(visited[i]==s)
19584 178 beenhere=true;
19585
19586
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 400 times.
578 if(!beenhere)
19587 {
19588 400 visited[vhead]=s;
19589 400 vhead = (vhead+1)%6;
19590 400 }
19591
2/2
✓ Branch 0 taken 139 times.
✓ Branch 1 taken 39 times.
178 else if(game->guys[s]==0)
19592 {
19593 39 sle_cnt=0;
19594 39 reload=false;
19595 39 }
19596
19597
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 539 times.
578 if(reload)
19598 {
19599 539 sle_cnt = game->guys[s];
19600
19601
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 539 times.
✓ Branch 2 taken 362 times.
✓ Branch 3 taken 177 times.
539 if((get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)
19602 539 || sle_cnt==0)
19603 {
19604
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 981 times.
✓ Branch 2 taken 806 times.
✓ Branch 3 taken 177 times.
983 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19605 806 ++sle_cnt;
19606 177 }
19607
3/4
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 139 times.
✓ Branch 2 taken 400 times.
✗ Branch 3 not taken.
539 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
19608 {
19609 for(int32_t i = 0; i<sle_cnt && tmpscr->enemy[i]>0; i++)
19610 {
19611 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
19612 {
19613 unbeatablereload = false;
19614 }
19615 }
19616 if (unbeatablereload)
19617 {
19618 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19619 {
19620 ++sle_cnt;
19621 }
19622 }
19623 }
19624 539 }
19625
19626
2/4
✓ Branch 0 taken 578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 578 times.
578 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN))
19627 {
19628 sle_cnt = 0;
19629
19630 while(sle_cnt<10 && tmpscr->enemy[sle_cnt]!=0)
19631 ++sle_cnt;
19632 }
19633
19634
2/2
✓ Branch 0 taken 1889 times.
✓ Branch 1 taken 578 times.
2467 for(int32_t i=0; i<sle_cnt; i++)
19635 1889 ++guycnt;
19636
19637 578 game->guys[s] = guycnt;
19638 578 }
19639
19640
2/2
✓ Branch 0 taken 41020 times.
✓ Branch 1 taken 1932 times.
42952 if((++sle_clk+8)%24 == 0)
19641 {
19642 1932 int32_t dir = next_side_pos(sle_pattern==pSIDESR);
19643
19644
4/4
✓ Branch 0 taken 1931 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 1739 times.
1932 if(dir==-1 || tooclose(sle_x,sle_y,32))
19645 {
19646 193 return;
19647 }
19648
19649 1739 int32_t enemy_slot=guys.Count();
19650
19651
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1739 times.
1739 while(sle_cnt > 0 && !ok2add(tmpscr->enemy[sle_cnt-1]))
19652 sle_cnt--;
19653
19654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(sle_cnt > 0)
19655 {
19656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if(addenemy(sle_x,sle_y,tmpscr->enemy[--sle_cnt],0))
19657 {
19658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1739 times.
1739 if (((enemy*)guys.spr(enemy_slot))->family != eeTEK)
19659 {
19660 1739 guys.spr(enemy_slot)->dir = dir;
19661 1739 }
19662
1/2
✓ Branch 0 taken 1739 times.
✗ Branch 1 not taken.
1739 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19663 {
19664 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19665 {
19666 guys.spr(enemy_slot)->run_script(MODE_NORMAL);
19667 ((enemy*)guys.spr(enemy_slot))->didScriptThisFrame = true;
19668 }
19669 }
19670 1739 }
19671 1739 }
19672 1739 }
19673
19674
2/2
✓ Branch 0 taken 42248 times.
✓ Branch 1 taken 511 times.
42759 if(sle_cnt<=0)
19675 {
19676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 511 times.
511 if(script_sle)
19677 script_sle = false;
19678 511 else loaded_enemies=true;
19679 511 sle_clk = 0;
19680 511 }
19681 42952 }
19682
19683 1125376 bool is_starting_pos(int32_t i, int32_t x, int32_t y, int32_t t)
19684 {
19685
19686
4/4
✓ Branch 0 taken 1025602 times.
✓ Branch 1 taken 99774 times.
✓ Branch 2 taken 99774 times.
✓ Branch 3 taken 1125376 times.
1125376 if(tmpscr->enemy[i]<1||tmpscr->enemy[i]>=MAXGUYS) //Hackish fix for crash in Waterford.st on screen 0x65 of dmap 0 (map 1).
19687 {
19688 //zprint2("is_starting_pos(), tmpscr->enemy[i] is: %d\n", tmpscr->enemy[i]);
19689 199548 return false; //never 0, never OoB.
19690 }
19691 // No corner enemies
19692
6/6
✓ Branch 0 taken 964629 times.
✓ Branch 1 taken 160747 times.
✓ Branch 2 taken 38801 times.
✓ Branch 3 taken 1003430 times.
✓ Branch 4 taken 110860 times.
✓ Branch 5 taken 88688 times.
1125376 if((x==0 || x==240) && (y==0 || y==160))
19693
19694 199548 return false;
19695
19696 //Is a no spawn combo...
19697
3/4
✓ Branch 0 taken 1003426 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1003426 times.
1003430 if(MAPFLAG(x+8,y+8)==mfNOENEMYSPAWN || MAPCOMBOFLAG(x+8,y+8)==mfNOENEMYSPAWN)
19698 4 return false;
19699
19700 // No enemies in dungeon walls
19701
10/10
✓ Branch 0 taken 632806 times.
✓ Branch 1 taken 370620 times.
✓ Branch 2 taken 561286 times.
✓ Branch 3 taken 71520 times.
✓ Branch 4 taken 489766 times.
✓ Branch 5 taken 71520 times.
✓ Branch 6 taken 403942 times.
✓ Branch 7 taken 85824 times.
✓ Branch 8 taken 85824 times.
✓ Branch 9 taken 318118 times.
1003426 if(isdungeon() && (x<32 || x>=224 || y<32 || y>=144))
19702 314688 return false;
19703
19704 // Too close
19705
4/4
✓ Branch 0 taken 69962 times.
✓ Branch 1 taken 618776 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 69939 times.
688738 if(tooclose(x,y,40) && t<11)
19706 69939 return false;
19707
19708 // Can't fly onto it?
19709
4/4
✓ Branch 0 taken 115623 times.
✓ Branch 1 taken 503176 times.
✓ Branch 2 taken 34519 times.
✓ Branch 3 taken 16220 times.
669538 if(isflier(tmpscr->enemy[i])&&
19710
2/2
✓ Branch 0 taken 115367 times.
✓ Branch 1 taken 256 times.
115623 (flyerblocked(x+8,y+8,spw_floater,guysbuf[tmpscr->enemy[i]])||
19711
2/2
✓ Branch 0 taken 50739 times.
✓ Branch 1 taken 64628 times.
115367 (_walkflag(x,y+8,2)&&!get_qr(qr_WALLFLIERS))))
19712 16476 return false;
19713
19714 // Can't jump onto it?
19715 if
19716 (
19717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84754 times.
687077 guysbuf[tmpscr->enemy[i]].family==eeTEK
19718
19719
2/2
✓ Branch 0 taken 84754 times.
✓ Branch 1 taken 517569 times.
602323 &&
19720 (
19721
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOJUMPZONE||
19722
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 COMBOTYPE(x+8,y+8)==cNOENEMY||
19723
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 ispitfall(x+8,y+8)||
19724
1/2
✓ Branch 0 taken 84754 times.
✗ Branch 1 not taken.
84754 MAPFLAG(x+8,y+8)==mfNOENEMY||
19725 84754 MAPCOMBOFLAG(x+8,y+8)==mfNOENEMY
19726 )
19727 )
19728 {
19729 return false;
19730 }
19731
19732 // Other off-limit combos
19733
6/6
✓ Branch 0 taken 503176 times.
✓ Branch 1 taken 99147 times.
✓ Branch 2 taken 418422 times.
✓ Branch 3 taken 84754 times.
✓ Branch 4 taken 239151 times.
✓ Branch 5 taken 179271 times.
1020745 if((!isflier(tmpscr->enemy[i])&& guysbuf[tmpscr->enemy[i]].family!=eeTEK &&
19734
2/2
✓ Branch 0 taken 242814 times.
✓ Branch 1 taken 175608 times.
418422 (_walkflag(x,y+8,2) || groundblocked(x+8,y+8,guysbuf[tmpscr->enemy[i]]))) &&
19735 418422 guysbuf[tmpscr->enemy[i]].family!=eeZORA)
19736 179271 return false;
19737
19738 // Don't ever generate enemies on these combos!
19739
3/4
✓ Branch 0 taken 422753 times.
✓ Branch 1 taken 299 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 422753 times.
423052 if(COMBOTYPE(x+8,y+8)==cARMOS||COMBOTYPE(x+8,y+8)==cBSGRAVE)
19740 299 return false;
19741
19742 //BS Dodongos need at least 2 spaces.
19743
4/4
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 421789 times.
✓ Branch 2 taken 962 times.
✓ Branch 3 taken 2 times.
422753 if((guysbuf[tmpscr->enemy[i]].family==eeDONGO)&&(guysbuf[tmpscr->enemy[i]].misc10==1))
19744 {
19745
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(((x<16) ||_walkflag(x-16,y+8, 2))&&
19746 ((x>224)||_walkflag(x+16,y+8, 2))&&
19747 ((y<16) ||_walkflag(x, y-8, 2))&&
19748 ((y>144)||_walkflag(x, y+24,2)))
19749 {
19750 return false;
19751 }
19752 2 }
19753
19754 422753 return true;
19755 1025602 }
19756
19757 79304 bool is_ceiling_pattern(int32_t i)
19758 {
19759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79304 times.
79304 return (i==pCEILING || i==pCEILINGR);
19760 }
19761
19762 5543 int32_t placeenemy(int32_t i)
19763 {
19764 5543 std::map<int32_t, int32_t> freeposcache;
19765 5543 int32_t frees = 0;
19766
19767
2/2
✓ Branch 0 taken 60973 times.
✓ Branch 1 taken 5543 times.
66516 for(int32_t y=0; y<176; y+=16)
19768 {
19769
2/2
✓ Branch 0 taken 975568 times.
✓ Branch 1 taken 60973 times.
1036541 for(int32_t x=0; x<256; x+=16)
19770 {
19771
3/4
✓ Branch 0 taken 975568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 391343 times.
✓ Branch 3 taken 584225 times.
975568 if(is_starting_pos(i,x,y,0))
19772 {
19773
1/2
✓ Branch 0 taken 391343 times.
✗ Branch 1 not taken.
391343 freeposcache[frees++] = (y&0xF0)+(x>>4);
19774 391343 }
19775 975568 }
19776 60973 }
19777
19778
2/2
✓ Branch 0 taken 5532 times.
✓ Branch 1 taken 11 times.
5543 if(frees > 0)
19779
2/4
✓ Branch 0 taken 5532 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5532 times.
✗ Branch 3 not taken.
5532 return freeposcache[zc_oldrand()%frees];
19780
19781 11 return -1;
19782 5543 }
19783
19784 39969 void spawnEnemy(int& pos, int& clk, int& x, int& y, int& fastguys, int& i, int& guycnt, int& loadcnt)
19785 {
19786 39969 bool placed=false;
19787 39969 int32_t t=-1;
19788
19789 // First: enemy combo flags
19790
2/2
✓ Branch 0 taken 424419 times.
✓ Branch 1 taken 36953 times.
461372 for(int32_t sy=0; sy<176; sy+=16)
19791 {
19792
2/2
✓ Branch 0 taken 6768453 times.
✓ Branch 1 taken 421403 times.
7189856 for(int32_t sx=0; sx<256; sx+=16)
19793 {
19794 6768453 int32_t cflag = MAPFLAG(sx, sy);
19795 6768453 int32_t cflag_i = MAPCOMBOFLAG(sx, sy);
19796
19797
2/4
✓ Branch 0 taken 6768453 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6768453 times.
✗ Branch 3 not taken.
6768453 if(((cflag==mfENEMYALL)||(cflag_i==mfENEMYALL)) && (!placed))
19798 {
19799 if(!ok2add(tmpscr->enemy[i]))
19800 {
19801 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19802 }
19803 else
19804 {
19805 addenemy(sx,
19806 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19807 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19808
19809 ++guycnt;
19810
19811 placed=true;
19812 goto placed_enemy;
19813 }
19814 }
19815
19816
4/4
✓ Branch 0 taken 6765435 times.
✓ Branch 1 taken 3018 times.
✓ Branch 2 taken 6765435 times.
✓ Branch 3 taken 3018 times.
6768453 else if(((cflag==mfENEMY0+i)||(cflag_i==mfENEMY0+i)) && (!placed))
19817 {
19818
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3016 times.
3018 if(!ok2add(tmpscr->enemy[i]))
19819 {
19820
3/6
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
2 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19821 2 }
19822 else
19823 {
19824 6032 addenemy(sx,
19825
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : sy,
19826
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3016 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3016 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],-15);
19827
19828 3016 ++guycnt;
19829
19830 3016 placed=true;
19831 3016 goto placed_enemy;
19832 }
19833 2 }
19834 6765437 }
19835 421403 }
19836
19837 // Next: enemy pattern
19838
6/8
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 32061 times.
✓ Branch 2 taken 31495 times.
✓ Branch 3 taken 5458 times.
✓ Branch 4 taken 31495 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 31495 times.
36953 if((tmpscr->pattern==pRANDOM || tmpscr->pattern==pCEILING) && !(isSideViewGravity()) && ((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS)))
19839 {
19840 31495 do
19841 {
19842
19843 // NES positions
19844 50119 pos%=9;
19845 50119 x=stx[loadside][pos];
19846 50119 y=sty[loadside][pos];
19847 50119 ++pos;
19848 50119 ++t;
19849
2/2
✓ Branch 0 taken 18624 times.
✓ Branch 1 taken 31495 times.
81614 }
19850
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 50034 times.
50119 while((t< 20) && !is_starting_pos(i,x,y,t));
19851 31495 }
19852
19853
4/4
✓ Branch 0 taken 31495 times.
✓ Branch 1 taken 5458 times.
✓ Branch 2 taken 85 times.
✓ Branch 3 taken 31410 times.
36953 if(t<0 || t >= 20) // above enemy pattern failed
19854 {
19855 // Final chance: find a random position anywhere onscreen
19856 5543 int32_t randpos = placeenemy(i);
19857
19858
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 5532 times.
5543 if(randpos>-1)
19859 {
19860 5532 x=(randpos&15)<<4;
19861 5532 y= randpos&0xF0;
19862 5532 }
19863 else // All opportunities failed - abort
19864 {
19865 11 return;
19866 }
19867 5532 }
19868
19869 {
19870 36942 int32_t c=0;
19871 36942 c=clk;
19872
19873
2/2
✓ Branch 0 taken 5563 times.
✓ Branch 1 taken 31379 times.
36942 if(!slowguy(tmpscr->enemy[i]))
19874 31379 ++fastguys;
19875
2/2
✓ Branch 0 taken 851 times.
✓ Branch 1 taken 4712 times.
5563 else if(fastguys>0)
19876 851 c=-15*(i-fastguys+2);
19877 else
19878 4712 c=-15*(i+1);
19879
19880
4/6
✓ Branch 0 taken 7804 times.
✓ Branch 1 taken 29138 times.
✓ Branch 2 taken 7804 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 7804 times.
36942 if(BSZ&&((tmpscr->enemy[i]>0&&tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19881 {
19882 // Special case for blue leevers
19883
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 7802 times.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
7804 if(guysbuf[tmpscr->enemy[i]].family==eeLEV && guysbuf[tmpscr->enemy[i]].misc1==1)
19884 2 c=-15*(i+1);
19885 else
19886 7802 c=-15;
19887 7804 }
19888
19889
2/2
✓ Branch 0 taken 36636 times.
✓ Branch 1 taken 306 times.
36942 if(!ok2add(tmpscr->enemy[i]))
19890 {
19891
4/6
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 250 times.
✓ Branch 2 taken 56 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
306 if (loadcnt < 10 && tmpscr->enemy[i] > 0 && tmpscr->enemy[i] < MAXGUYS) ++loadcnt;
19892 306 }
19893 else
19894 {
19895
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36636 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
36636 if(((tmpscr->enemy[i]>0||tmpscr->enemy[i]<MAXGUYS))) // Hackish fix for crash in Waterford.qst on screen 0x65 of dmap 0 (map 1).
19896 {
19897
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✓ Branch 2 taken 83 times.
✗ Branch 3 not taken.
73272 addenemy(x,(is_ceiling_pattern(tmpscr->pattern) && isSideViewGravity()) ? -(150+50*guycnt) : y,
19898
3/4
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 36553 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 83 times.
36636 (is_ceiling_pattern(tmpscr->pattern) && !(isSideViewGravity())) ? 150+50*guycnt : 0,tmpscr->enemy[i],c);
19899
19900 36636 ++guycnt;
19901 36636 }
19902 }
19903
19904 36942 placed=true;
19905 36942 } // if(t < 20)
19906
19907 placed_enemy:
19908
19909 // I don't like this, but it seems to work...
19910 static bool foundCarrier;
19911
19912
2/2
✓ Branch 0 taken 30369 times.
✓ Branch 1 taken 9589 times.
39958 if(i==0)
19913 9589 foundCarrier=false;
19914
19915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39958 times.
39958 if(placed)
19916 {
19917
4/4
✓ Branch 0 taken 9589 times.
✓ Branch 1 taken 30369 times.
✓ Branch 2 taken 9446 times.
✓ Branch 3 taken 143 times.
39958 if(i==0 && tmpscr->enemyflags&efLEADER)
19918 {
19919 143 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19920
19921
2/2
✓ Branch 0 taken 136 times.
✓ Branch 1 taken 7 times.
143 if(index!=-1)
19922 {
19923 //grab the first segment. Not accurate to how older versions did it, but the way they did it might be incompatible with enemy editor.
19924
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
136 if ((((enemy*)guys.spr(index))->family == eeLANM) && !get_qr(qr_NO_LANMOLA_RINGLEADER)) index = guys.idNth(tmpscr->enemy[i], 2, 0xFFF);
19925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(index!=-1)
19926 {
19927 136 ((enemy*)guys.spr(index))->leader = true;
19928 136 }
19929 136 }
19930 143 }
19931
19932
4/4
✓ Branch 0 taken 39858 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 39824 times.
✓ Branch 3 taken 34 times.
39958 if(!foundCarrier && hasitem&(4|2))
19933 {
19934 34 int32_t index = guys.idFirst(tmpscr->enemy[i],0xFFF);
19935
19936
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if(index!=-1 && (((enemy*)guys.spr(index))->flags&guy_doesntcount)==0)
19937 {
19938 34 ((enemy*)guys.spr(index))->itemguy = true;
19939 34 foundCarrier=true;
19940 34 }
19941 34 }
19942 39958 }
19943 39969 }
19944
19945 bool scriptloadenemies()
19946 {
19947 loaded_enemies = true;
19948 if(script_sle || sle_clk) return false;
19949 if(tmpscr->pattern==pNOSPAWN) return false;
19950
19951 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
19952 {
19953 script_side_load_enemies();
19954 return true;
19955 }
19956
19957 int32_t pos=zc_oldrand()%9;
19958 int32_t clk=-15,x=0,y=0,fastguys=0;
19959 int32_t i=0,guycnt=0;
19960 int32_t loadcnt = 10;
19961
19962 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
19963 {
19964 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
19965 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
19966 if (guys.Count() > preguycount)
19967 {
19968 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
19969 {
19970 if (!FFCore.system_suspend[susptNPCSCRIPTS])
19971 {
19972 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
19973 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
19974 }
19975 }
19976 }
19977 --clk;
19978 }
19979 return true;
19980 }
19981
19982 7246673 void loadenemies()
19983 {
19984
3/4
✓ Branch 0 taken 7246673 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 42374 times.
✓ Branch 3 taken 7204299 times.
7246673 if(script_sle || sle_clk)
19985 {
19986 42374 side_load_enemies();
19987 42374 return;
19988 }
19989
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7204299 times.
7204299 if(tmpscr->pattern==pNOSPAWN) return;
19990
2/2
✓ Branch 0 taken 7188093 times.
✓ Branch 1 taken 16206 times.
7204299 if(loaded_enemies)
19991 7188093 return;
19992
19993 // check if it's the dungeon boss and it has been beaten before
19994
4/4
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 15958 times.
✓ Branch 2 taken 178 times.
✓ Branch 3 taken 70 times.
16206 if(tmpscr->enemyflags&efBOSS && game->lvlitems[dlevel]&liBOSS)
19995 {
19996 70 loaded_enemies = true;
19997 70 return;
19998 }
19999
20000
4/4
✓ Branch 0 taken 15799 times.
✓ Branch 1 taken 337 times.
✓ Branch 2 taken 241 times.
✓ Branch 3 taken 15558 times.
16136 if(tmpscr->pattern==pSIDES || tmpscr->pattern==pSIDESR)
20001 {
20002 578 side_load_enemies();
20003 578 return;
20004 }
20005
20006 15558 loaded_enemies=true;
20007
20008 // do enemies that are always loaded
20009 15558 load_default_enemies();
20010
20011 // dungeon basements
20012
20013 static byte dngn_enemy_x[4] = {32,96,144,208};
20014
20015
2/2
✓ Branch 0 taken 679 times.
✓ Branch 1 taken 14879 times.
15558 if(currscr>=128)
20016 {
20017
2/2
✓ Branch 0 taken 339 times.
✓ Branch 1 taken 340 times.
679 if(DMaps[currdmap].flags&dmfCAVES) return;
20018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 340 times.
340 if ( DMaps[currdmap].flags&dmfNEWCELLARENEMIES )
20019 {
20020 for(int32_t i=0; i<10; i++)
20021 {
20022 if ( tmpscr->enemy[i] )
20023 {
20024 int32_t preguycount = guys.Count();
20025 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i],-14-i);
20026 if (guys.Count() > preguycount)
20027 {
20028 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20029 {
20030 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20031 {
20032 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20033 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20034 }
20035 }
20036 }
20037 }
20038 }
20039 }
20040 else
20041 {
20042
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 340 times.
1700 for(int32_t i=0; i<4; i++)
20043 {
20044 1360 int32_t preguycount = guys.Count();
20045
2/2
✓ Branch 0 taken 964 times.
✓ Branch 1 taken 396 times.
1360 addenemy(dngn_enemy_x[i],96,tmpscr->enemy[i]?tmpscr->enemy[i]:(int32_t)eKEESE1,-14-i);
20046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1360 times.
1360 if (guys.Count() > preguycount)
20047 {
20048
1/2
✓ Branch 0 taken 1360 times.
✗ Branch 1 not taken.
1360 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20049 {
20050 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20051 {
20052 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20053 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20054 }
20055 }
20056 1360 }
20057 1360 }
20058 }
20059 340 return;
20060 }
20061
20062 // check if it's been long enough to reload all enemies
20063
20064 14879 int32_t loadcnt = 10;
20065 14879 int16_t s = (currmap<<7)+currscr;
20066 14879 bool beenhere = false;
20067 14879 bool reload = true;
20068 14879 bool unbeatablereload = true;
20069
20070
2/2
✓ Branch 0 taken 89274 times.
✓ Branch 1 taken 14879 times.
104153 for(int32_t i=0; i<6; i++)
20071
2/2
✓ Branch 0 taken 84942 times.
✓ Branch 1 taken 4332 times.
93606 if(visited[i]==s)
20072 4332 beenhere = true;
20073
20074
2/2
✓ Branch 0 taken 4332 times.
✓ Branch 1 taken 10547 times.
14879 if(!beenhere) //Okay so this basically checks the last 6 unique screen's you've been in and checks if the current screen is one of them.
20075 {
20076 10547 visited[vhead]=s; //If not, it adds it to the array,
20077 10547 vhead = (vhead+1)%6; //which overrides one of the others, and then moves onto the next.
20078 10547 }
20079
2/2
✓ Branch 0 taken 2001 times.
✓ Branch 1 taken 2331 times.
4332 else if(game->guys[s]==0) //Then, if you have been here, and the number of enemies left on the screen is 0,
20080 {
20081 2331 loadcnt = 0; //It will tell it not to load any enemies,
20082 2331 reload = false; //both by setting loadcnt to 0 and making the reload if statement not run.
20083 2331 }
20084
20085
2/2
✓ Branch 0 taken 2331 times.
✓ Branch 1 taken 12548 times.
14879 if(reload) //This if statement is only false if this screen is one of the last 6 screens you visited and you left 0 enemies alive.
20086 {
20087 12548 loadcnt = game->guys[s]; //Otherwise, if this if statement is true, it will try to load the last amount of enemies you left alive.
20088
20089
2/4
✓ Branch 0 taken 4249 times.
✓ Branch 1 taken 8299 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12548 if(loadcnt==0 || //Then, if the number of enemies is 0, that means you left 0 enemies alive on a screen but haven't been there in the past 6 screens.
20090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4249 times.
4249 (get_qr(qr_NO_LEAVE_ONE_ENEMY_ALIVE_TRICK) && !beenhere)) //Alternatively, if you have the quest rule enabled that always respawns all enemies after a period of time, and you haven't been here in 6 screens.
20091 8299 loadcnt = 10; //That means all enemies need to be respawned.
20092
3/4
✓ Branch 0 taken 10547 times.
✓ Branch 1 taken 2001 times.
✓ Branch 2 taken 10547 times.
✗ Branch 3 not taken.
12548 if (!beenhere && get_qr(qr_UNBEATABLES_DONT_KEEP_DEAD))
20093 {
20094 for(int32_t i = 0; i<loadcnt && tmpscr->enemy[i]>0; i++)
20095 {
20096 if (!(guysbuf[tmpscr->enemy[i]].flags & guy_doesntcount))
20097 {
20098 unbeatablereload = false;
20099 }
20100 }
20101 if (unbeatablereload)
20102 {
20103 loadcnt = 10;
20104 }
20105 }
20106 12548 }
20107
20108
4/4
✓ Branch 0 taken 14229 times.
✓ Branch 1 taken 650 times.
✓ Branch 2 taken 50 times.
✓ Branch 3 taken 14179 times.
14879 if((get_qr(qr_ALWAYSRET)) || (tmpscr->flags3&fENEMIESRETURN)) //If enemies always return is enabled quest-wide or for this screen,
20109 700 loadcnt = 10; //All enemies also need to be respawned.
20110
20111 14879 int32_t pos=zc_oldrand()%9; //This sets up a variable for spawnEnemy to edit so as to spawn the enemies pseudo-randomly.
20112 14879 int32_t clk=-15,x=0,y=0,fastguys=0; //clk being negative means the enemy is in its spawn poof.
20113 14879 int32_t i=0,guycnt=0; //Lastly, resets guycnt to 0 so spawnEnemy can increment it manually per-enemy.
20114
20115
4/4
✓ Branch 0 taken 6581 times.
✓ Branch 1 taken 48267 times.
✓ Branch 2 taken 39969 times.
✓ Branch 3 taken 14879 times.
54848 for(; i<loadcnt && tmpscr->enemy[i]>0; i++)
20116 {
20117 39969 int32_t preguycount = guys.Count(); //I'm not experienced enough to know if this is an awful hack but it feels like one.
20118 39969 spawnEnemy(pos, clk, x, y, fastguys, i, guycnt, loadcnt);
20119
2/2
✓ Branch 0 taken 317 times.
✓ Branch 1 taken 39652 times.
39969 if (guys.Count() > preguycount)
20120 {
20121
1/2
✓ Branch 0 taken 39652 times.
✗ Branch 1 not taken.
39652 if (!get_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME))
20122 {
20123 if (!FFCore.system_suspend[susptNPCSCRIPTS])
20124 {
20125 guys.spr(guys.Count()-1)->run_script(MODE_NORMAL);
20126 ((enemy*)guys.spr(guys.Count()-1))->didScriptThisFrame = true;
20127 }
20128 }
20129 39652 }
20130
20131 39969 --clk; //Each additional enemy spawns with a slightly longer spawn poof than the previous.
20132 39969 }
20133
20134 14879 game->guys[s] = guycnt;
20135 //} //if(true)
20136 7246673 }
20137 147 void moneysign()
20138 {
20139 147 additem(48,108,iRupy,ipDUMMY);
20140 // textout(scrollbuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1);
20141 147 set_clip_state(pricesdisplaybuf, 0);
20142 147 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),"X",64,112,CSET(0)+1,-1);
20143 147 }
20144
20145 1571 void putprices(bool sign)
20146 {
20147
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1565 times.
1571 if(fadeclk > 0) return;
20148 // refresh what's under the prices
20149 // for(int32_t i=5; i<12; i++)
20150 // putcombo(scrollbuf,i<<4,112,tmpscr->data[112+i],tmpscr->cpage);
20151
20152 1565 rectfill(pricesdisplaybuf, 72, 112, pricesdisplaybuf->w-1, pricesdisplaybuf->h-1, 0);
20153 1565 int32_t step=32;
20154 1565 int32_t x=80;
20155
20156
2/2
✓ Branch 0 taken 178 times.
✓ Branch 1 taken 1387 times.
1565 if(prices[2]==0)
20157 {
20158 1387 step<<=1;
20159
20160
2/2
✓ Branch 0 taken 1360 times.
✓ Branch 1 taken 27 times.
1387 if(prices[1]==0)
20161 {
20162 1360 x=112;
20163 1360 }
20164 1387 }
20165
20166
2/2
✓ Branch 0 taken 1565 times.
✓ Branch 1 taken 4695 times.
6260 for(int32_t i=0; i<3; i++)
20167 {
20168 // Kind of stupid, but it works: 100000 is used to indicate that an item
20169 // has a price of zero rather than there being no item.
20170 // 100000 isn't a valid price, so this doesn't cause problems.
20171
3/4
✓ Branch 0 taken 692 times.
✓ Branch 1 taken 4003 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 692 times.
4695 if(prices[i]!=0 && prices[i]<100000)
20172 {
20173 char buf[8];
20174 692 sprintf(buf,sign?"%+3d":"%3d",prices[i]);
20175
20176 692 int32_t l=(int32_t)strlen(buf);
20177 692 set_clip_state(pricesdisplaybuf, 0);
20178
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 671 times.
692 textout_ex(pricesdisplaybuf,get_zc_font(font_zfont),buf,x-(l>3?(l-3)<<3:0),112,CSET(0)+1,-1);
20179 692 }
20180
20181 4695 x+=step;
20182 4695 }
20183 1571 }
20184
20185 // Setting up special rooms
20186 // Also called when the Letter is used successfully.
20187 721 void setupscreen()
20188 {
20189 721 boughtsomething=false;
20190 721 int32_t t=currscr<128?0:1;
20191 721 word str=tmpscr[t].str;
20192
20193 // Prices are already set to 0 in dowarp()
20194
13/15
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 366 times.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 12 times.
✓ Branch 7 taken 1 times.
✓ Branch 8 taken 2 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 32 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 13 times.
721 switch(tmpscr[t].room)
20195 {
20196 case rSP_ITEM: // special item
20197 105 additem(120,89,tmpscr[t].catchall,ipONETIME2+ipHOLDUP+ipCHECK | ((tmpscr->flags8&fITEMSECRET) ? ipSECRETS : 0));
20198 105 break;
20199
20200 case rINFO: // pay for info
20201 {
20202 14 int32_t count = 0;
20203 14 int32_t base = 88;
20204 14 int32_t step = 5;
20205
20206 14 moneysign();
20207
20208
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 42 times.
56 for(int32_t i=0; i<3; i++)
20209 {
20210
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(QMisc.info[tmpscr[t].catchall].str[i])
20211 {
20212 42 ++count;
20213 42 }
20214 else
20215 break;
20216 42 }
20217
20218
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 if(count)
20219 {
20220
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==1)
20221 {
20222 base = 88+32;
20223 }
20224
20225
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(count==2)
20226 {
20227 step = 6;
20228 }
20229
20230
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 14 times.
56 for(int32_t i=0; i < count; i++)
20231 {
20232 42 additem((i << step)+base, 89, iRupy, ipMONEY + ipDUMMY);
20233 42 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20234 42 prices[i] = -(QMisc.info[tmpscr[t].catchall].price[i]);
20235
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 if(prices[i]==0)
20236 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20237 42 int32_t itemid = current_item_id(itype_wealthmedal);
20238
20239
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42 if(itemid>=0 && prices[i]!=100000)
20240 {
20241 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20242 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20243 else
20244 prices[i]-=itemsbuf[itemid].misc1;
20245 prices[i]=vbound(prices[i], -99999, 0);
20246 if(prices[i]==0)
20247 prices[i]=100000;
20248 }
20249
20250
2/6
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
42 if((QMisc.info[tmpscr[t].catchall].price[i])>1 && prices[i]>-1 && prices[i]!=100000)
20251 prices[i]=-1;
20252 42 }
20253 14 }
20254
20255 14 break;
20256 }
20257
20258 case rMONEY: // secret money
20259 38 additem(120,89,iRupy,ipONETIME+ipDUMMY+ipMONEY);
20260 38 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20261 38 break;
20262
20263 case rGAMBLE: // gambling
20264 7 prices[0]=prices[1]=prices[2]=-10;
20265 7 moneysign();
20266 7 additem(88,89,iRupy,ipMONEY+ipDUMMY);
20267 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20268 7 additem(120,89,iRupy,ipMONEY+ipDUMMY);
20269 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20270 7 additem(152,89,iRupy,ipMONEY+ipDUMMY);
20271 7 ((item*)items.spr(items.Count()-1))->PriceIndex = 2;
20272 7 break;
20273
20274 case rREPAIR: // door repair
20275
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
20276 // }
20277 12 repaircharge=tmpscr[t].catchall;
20278 12 break;
20279
20280 case rMUPGRADE: // upgrade magic
20281 1 adjustmagic=true;
20282 1 break;
20283
20284 case rLEARNSLASH: // learn slash attack
20285 2 learnslash=true;
20286 2 break;
20287
20288 case rRP_HC: // heart container or red potion
20289 12 additem(88,89,iRPotion,ipONETIME2+ipHOLDUP+ipFADE);
20290 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20291 12 additem(152,89,iHeartC,ipONETIME2+ipHOLDUP+ipFADE);
20292 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20293 12 break;
20294
20295 case rP_SHOP: // potion shop
20296
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 20 times.
32 if(current_item(itype_letter)<i_letter_used)
20297 {
20298 12 str=0;
20299 12 break;
20300 }
20301
20302 [[fallthrough]];
20303 case rTAKEONE: // take one
20304 case rSHOP: // shop
20305 {
20306 127 int32_t count = 0;
20307 127 int32_t base = 88;
20308 127 int32_t step = 5;
20309
20310
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 126 times.
127 if(tmpscr[t].room != rTAKEONE)
20311 126 moneysign();
20312
20313 //count and align the stuff
20314
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 363 times.
461 for(int32_t i=0; i<3; ++i)
20315 {
20316
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 29 times.
363 if(QMisc.shop[tmpscr[t].catchall].hasitem[count] != 0)
20317 {
20318 334 ++count;
20319 334 }
20320 else
20321 {
20322 29 break;
20323 }
20324 334 }
20325
20326
2/2
✓ Branch 0 taken 109 times.
✓ Branch 1 taken 18 times.
127 if(count==1)
20327 {
20328 18 base = 88+32;
20329 18 }
20330
20331
2/2
✓ Branch 0 taken 116 times.
✓ Branch 1 taken 11 times.
127 if(count==2)
20332 {
20333 11 step = 6;
20334 11 }
20335
20336
2/2
✓ Branch 0 taken 334 times.
✓ Branch 1 taken 127 times.
461 for(int32_t i=0; i<count; i++)
20337 {
20338 334 additem((i<<step)+base, 89, QMisc.shop[tmpscr[t].catchall].item[i], ipHOLDUP+ipFADE+(tmpscr[t].room == rTAKEONE ? ipONETIME2 : ipCHECK));
20339 334 ((item*)items.spr(items.Count()-1))->PriceIndex = i;
20340
20341
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 332 times.
334 if(tmpscr[t].room != rTAKEONE)
20342 {
20343 332 prices[i] = QMisc.shop[tmpscr[t].catchall].price[i];
20344
1/2
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
332 if(prices[i]==0)
20345 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20346 332 int32_t itemid = current_item_id(itype_wealthmedal);
20347
20348
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 332 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
332 if(itemid>=0 && prices[i]!=100000)
20349 {
20350 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20351 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20352 else
20353 prices[i]+=itemsbuf[itemid].misc1;
20354 prices[i]=vbound(prices[i], 0, 99999);
20355 if(prices[i]==0)
20356 prices[i]=100000;
20357 }
20358
20359
2/4
✓ Branch 0 taken 332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 332 times.
✗ Branch 3 not taken.
332 if((QMisc.shop[tmpscr[t].catchall].price[i])>1 && prices[i]<1)
20360 prices[i]=1;
20361 332 }
20362 334 }
20363
20364 127 break;
20365 }
20366 case rBOTTLESHOP: // bottle shop
20367 {
20368 int32_t count = 0;
20369 int32_t base = 88;
20370 int32_t step = 5;
20371
20372 moneysign();
20373 bottleshoptype const& bst = QMisc.bottle_shop_types[tmpscr[t].catchall];
20374 //count and align the stuff
20375 for(int32_t i=0; i<3; ++i)
20376 {
20377 if(bst.fill[count] != 0)
20378 {
20379 ++count;
20380 }
20381 else
20382 {
20383 break;
20384 }
20385 }
20386
20387 if(count==1)
20388 {
20389 base = 88+32;
20390 }
20391
20392 if(count==2)
20393 {
20394 step = 6;
20395 }
20396
20397 for(int32_t i=0; i<count; i++)
20398 {
20399 adddummyitem((i<<step)+base, 89, /*Use item 0 as a dummy...*/0, ipHOLDUP+ipFADE+ipCHECK);
20400 //{ Setup dummy item
20401 item* curItem = ((item*)items.spr(items.Count()-1));
20402 curItem->PriceIndex = i;
20403 newcombo const& cmb = combobuf[bst.comb[i]];
20404 curItem->o_tile = cmb.o_tile;
20405 curItem->o_cset = bst.cset[i];
20406 curItem->cs = curItem->o_cset;
20407 curItem->tile = cmb.o_tile;
20408 curItem->o_speed = cmb.speed;
20409 curItem->o_delay = 0;
20410 curItem->frames = cmb.frames;
20411 curItem->flip = cmb.flip;
20412 curItem->family = itype_bottlefill; //no pickup w/o empty bottle
20413 curItem->pstring = 0;
20414 curItem->pickup = ipHOLDUP+ipFADE+ipCHECK;
20415 curItem->flash = false;
20416 curItem->twohand = false;
20417 curItem->anim = true;
20418 curItem->hit_width=1;
20419 curItem->hyofs=4;
20420 curItem->hit_height=12;
20421 curItem->script=0;
20422 curItem->txsz=1;
20423 curItem->tysz=1;
20424 //}
20425
20426 prices[i] = bst.price[i];
20427 if(prices[i]==0)
20428 prices[i]=100000; // So putprices() knows there's an item here and positions the price correctly
20429 int32_t itemid = current_item_id(itype_wealthmedal);
20430
20431 if(itemid>=0 && prices[i]!=100000)
20432 {
20433 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20434 prices[i]=((prices[i]*itemsbuf[itemid].misc1)/100);
20435 else
20436 prices[i]+=itemsbuf[itemid].misc1;
20437 prices[i]=vbound(prices[i], 0, 99999);
20438 if(prices[i]==0)
20439 prices[i]=100000;
20440 }
20441
20442 if((bst.price[i])>1 && prices[i]<1)
20443 prices[i]=1;
20444 }
20445
20446 break;
20447 }
20448
20449 case rBOMBS: // more bombs
20450 12 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20451 12 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20452 12 prices[0]=-tmpscr[t].catchall;
20453 12 break;
20454
20455 case rARROWS: // more arrows
20456 additem(120,89,iRupy,ipDUMMY+ipMONEY);
20457 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20458 prices[0]=-tmpscr[t].catchall;
20459 break;
20460
20461 case rSWINDLE: // leave heart container or money
20462 13 additem(88,89,iHeartC,ipDUMMY+ipMONEY);
20463 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 0;
20464 13 prices[0]=-1;
20465 13 additem(152,89,iRupy,ipDUMMY+ipMONEY);
20466 13 ((item*)items.spr(items.Count()-1))->PriceIndex = 1;
20467 13 prices[1]=-tmpscr[t].catchall;
20468 13 break;
20469
20470 }
20471
20472
3/4
✓ Branch 0 taken 709 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 709 times.
721 if(tmpscr[t].room == rBOMBS || tmpscr[t].room == rARROWS)
20473 {
20474 12 int32_t i = (tmpscr[t].room == rSWINDLE ? 1 : 0);
20475 12 int32_t itemid = current_item_id(itype_wealthmedal);
20476
20477
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(itemid >= 0)
20478 {
20479 if(itemsbuf[itemid].flags & ITEM_FLAG1)
20480 prices[i]*=(itemsbuf[itemid].misc1/100.0);
20481 else
20482 prices[i]+=itemsbuf[itemid].misc1;
20483 }
20484
20485
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(tmpscr[t].catchall>1 && prices[i]>-1)
20486 prices[i]=-1;
20487 12 }
20488
20489 721 putprices(false);
20490
20491
2/2
✓ Branch 0 taken 686 times.
✓ Branch 1 taken 35 times.
721 if(str)
20492 {
20493 686 donewmsg(str);
20494 686 }
20495 else
20496 {
20497 35 Hero.unfreeze();
20498 }
20499 721 }
20500
20501 // Increments msgptr and returns the control code argument pointed at.
20502 658 word grab_next_argument()
20503 {
20504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 658 times.
658 if(unsigned(msgptr+1)>=MsgStrings[msgstr].s.size()) return 0;
20505 658 byte val=MsgStrings[msgstr].s[++msgptr]-1;
20506 658 word ret=val;
20507
20508 // If an argument is succeeded by 255, then it's a three-byte argument -
20509 // between 254 and 65535 (or whatever the maximum actually is)
20510
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 if((unsigned(msgptr+2)<MsgStrings[msgstr].s.size())
20511
1/2
✓ Branch 0 taken 658 times.
✗ Branch 1 not taken.
658 && uint8_t(MsgStrings[msgstr].s[msgptr+1]) == 255)
20512 {
20513 val=MsgStrings[msgstr].s[msgptr+2];
20514 word next=val;
20515 ret += 254*next;
20516 msgptr+=2;
20517 }
20518
20519 658 return ret;
20520 658 }
20521
20522 enum
20523 {
20524 MNU_CURSOR_TILE, MNU_CURSOR_CSET,
20525 MNU_CURSOR_WID, MNU_CURSOR_HEI, MNU_CURSOR_FLIP,
20526
20527 MNU_CHOSEN, MNU_TIMER, MNU_CAN_CONFIRM,
20528
20529 MNU_DATA_MAX
20530 };
20531 struct menu_choice
20532 {
20533 int32_t x, y;
20534 int32_t pos;
20535 int32_t upos, dpos, lpos, rpos;
20536 menu_choice() : x(0), y(0), pos(0), upos(0), dpos(0), lpos(0), rpos(0)
20537 {}
20538 menu_choice(int32_t x, int32_t y, int32_t pos, int32_t upos,
20539 int32_t dpos, int32_t lpos, int32_t rpos)
20540 : x(x), y(y), pos(pos), upos(upos), dpos(dpos), lpos(lpos), rpos(rpos)
20541 {}
20542 };
20543 static int32_t msg_menu_data[MNU_DATA_MAX];
20544 static bool do_run_menu = false;
20545 bool do_end_str = false;
20546 static bool wait_advance = false;
20547 114 static std::map<int32_t, menu_choice> menu_options;
20548 19294 void clr_msg_data()
20549 {
20550 19294 do_end_str = false;
20551 19294 wait_advance = false;
20552 19294 do_run_menu = false;
20553 19294 menu_options.clear();
20554 19294 memset(msg_menu_data, 0, sizeof(msg_menu_data));
20555 19294 }
20556
20557 static bool doing_name_insert = false;
20558 static char namebuf[9] = {0};
20559 static char* nameptr = NULL;
20560 static int32_t ssc_tile_hei = -1, ssc_tile_hei_buf = -1;
20561 bool runMenuCursor()
20562 {
20563 clear_bitmap(msg_menu_bmp_buf);
20564 if(!menu_options.size())
20565 {
20566 msg_menu_data[MNU_CHOSEN] = 0;
20567 return true; //end menu
20568 }
20569 int32_t pos = msg_menu_data[MNU_CHOSEN];
20570 //If the cursor is at an invalid pos, find the first pos >= 0...
20571 if(menu_options.find(pos) == menu_options.end())
20572 {
20573 pos = 0;
20574 while(menu_options.find(pos) == menu_options.end())
20575 ++pos;
20576 }
20577 menu_choice* ch = &menu_options[pos];
20578
20579 bool pressed = true;
20580 if(rUp()) pos = ch->upos;
20581 else if(rDown()) pos = ch->dpos;
20582 else if(rLeft()) pos = ch->lpos;
20583 else if(rRight()) pos = ch->rpos;
20584 else pressed = false;
20585
20586 if(pressed)
20587 msg_menu_data[MNU_TIMER] = 1;
20588
20589 bool hold_input = !((msg_menu_data[MNU_TIMER]++) % 20);
20590 bool held = false;
20591 if(hold_input)
20592 {
20593 held = true;
20594 if(Up()) pos = ch->upos;
20595 else if(Down()) pos = ch->dpos;
20596 else if(Left()) pos = ch->lpos;
20597 else if(Right()) pos = ch->rpos;
20598 else held = false;
20599 }
20600 //If the cursor is at an invalid pos, find the first pos >= 0...
20601 if(menu_options.find(pos) == menu_options.end())
20602 {
20603 pos = 0;
20604 while(menu_options.find(pos) == menu_options.end())
20605 ++pos;
20606 }
20607 if((pressed || held) && pos != msg_menu_data[MNU_CHOSEN])
20608 sfx(MsgStrings[msgstr].sfx);
20609
20610 ch = &menu_options[pos];
20611 overtileblock16(msg_menu_bmp_buf, msg_menu_data[MNU_CURSOR_TILE],
20612 ch->x, ch->y, (int32_t)ceil(msg_menu_data[MNU_CURSOR_WID]/16.0),
20613 (int32_t)ceil(msg_menu_data[MNU_CURSOR_HEI]/16.0),
20614 msg_menu_data[MNU_CURSOR_CSET], msg_menu_data[MNU_CURSOR_FLIP]);
20615
20616 msg_menu_data[MNU_CHOSEN] = pos;
20617
20618 if(!msg_menu_data[MNU_CAN_CONFIRM]) //Prevent instantly accepting when holding A
20619 {
20620 rAbtn(); //Eat
20621 if(!cAbtn()) msg_menu_data[MNU_CAN_CONFIRM] = 1;
20622 }
20623
20624 bool ret = (pressed || held) ? false : rAbtn();
20625 //Eat inputs
20626 rUp(); rDown(); rLeft(); rRight(); rAbtn();
20627
20628 if(ret)
20629 menu_options.clear();
20630
20631 return ret;
20632 //false if pos changed this frame; no confirming while moving the cursor!
20633 }
20634
20635 184952 bool bottom_margin_clip()
20636 {
20637 185252 return !get_qr(qr_OLD_STRING_EDITOR_MARGINS)
20638
2/2
✓ Branch 0 taken 184652 times.
✓ Branch 1 taken 300 times.
184952 && cursor_y >= (msg_h + (get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)?16:0) - msg_margins[down]);
20639 }
20640
20641 void update_msgstr();
20642 98407 bool parsemsgcode()
20643 {
20644
2/2
✓ Branch 0 taken 601 times.
✓ Branch 1 taken 97806 times.
98407 if(msgptr>=MsgStrings[msgstr].s.size()) return false;
20645 97806 byte c = byte(MsgStrings[msgstr].s[msgptr]-1);
20646
5/38
✗ Branch 0 not taken.
✓ Branch 1 taken 97457 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 310 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 10 times.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
97806 switch(c)
20647 {
20648 case MSGC_NEWLINE:
20649 {
20650 1 ssc_tile_hei = ssc_tile_hei_buf;
20651
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20652 1 ssc_tile_hei_buf = -1;
20653 1 cursor_y += thei + MsgStrings[msgstr].vspace;
20654 1 cursor_x=msg_margins[left];
20655 1 return true;
20656 }
20657
20658 case MSGC_COLOUR:
20659 {
20660 310 int32_t cset = (grab_next_argument());
20661 310 msgcolour = CSET(cset)+(grab_next_argument());
20662 310 return true;
20663 }
20664
20665 case MSGC_SHDCOLOR:
20666 {
20667 int32_t cset = (grab_next_argument());
20668 msg_shdcol = CSET(cset)+(grab_next_argument());
20669 return true;
20670 }
20671 case MSGC_SHDTYPE:
20672 {
20673 msg_shdtype = grab_next_argument();
20674 return true;
20675 }
20676
20677 case MSGC_SPEED:
20678 {
20679 28 msgspeed=grab_next_argument();
20680 28 return true;
20681 }
20682
20683 case MSGC_CTRUP:
20684 {
20685 int32_t a1 = grab_next_argument();
20686 int32_t a2 = grab_next_argument();
20687 game->change_counter(a2, a1);
20688 return true;
20689 }
20690
20691 case MSGC_CTRDN:
20692 {
20693 int32_t a1 = grab_next_argument();
20694 int32_t a2 = grab_next_argument();
20695 game->change_counter(-a2, a1);
20696 return true;
20697 }
20698
20699 case MSGC_CTRSET:
20700 {
20701 int32_t a1 = grab_next_argument();
20702 int32_t a2 = grab_next_argument();
20703 game->set_counter(vbound(a2, 0, game->get_maxcounter(a1)), a1);
20704 return true;
20705 }
20706
20707 case MSGC_CTRUPPC:
20708 case MSGC_CTRDNPC:
20709 case MSGC_CTRSETPC:
20710 {
20711 int32_t code = MsgStrings[msgstr].s[msgptr]-1;
20712 int32_t counter = grab_next_argument();
20713 int32_t amount = grab_next_argument();
20714 amount = int32_t(vbound(amount*0.01, 0.0, 1.0)*game->get_maxcounter(counter));
20715
20716 if(code==MSGC_CTRDNPC)
20717 amount*=-1;
20718
20719 if(code==MSGC_CTRSETPC)
20720 game->set_counter(amount, counter);
20721 else
20722 game->change_counter(amount, counter);
20723
20724 return true;
20725 }
20726
20727 case MSGC_GIVEITEM:
20728 {
20729 int32_t itemID = grab_next_argument();
20730
20731 getitem(itemID, true);
20732 if ( !FFCore.doscript(ScriptType::Item, itemID) && (((unsigned)itemID) < 256) )
20733 {
20734 FFCore.reset_script_engine_data(ScriptType::Item, itemID);
20735 FFCore.doscript(ScriptType::Item, itemID) = (itemsbuf[itemID].flags&ITEM_PASSIVESCRIPT) > 0;
20736 }
20737 return true;
20738 }
20739
20740
20741 case MSGC_WARP:
20742 {
20743 int32_t dmap = grab_next_argument();
20744 int32_t scrn = grab_next_argument();
20745 int32_t dx = grab_next_argument();
20746 int32_t dy = grab_next_argument();
20747 int32_t wfx = grab_next_argument();
20748 int32_t sfx = grab_next_argument();
20749 if(dx >= MAX_SCC_ARG) dx = -1;
20750 if(dy >= MAX_SCC_ARG) dy = -1;
20751 FFCore.warp_player(wtIWARP, dmap, scrn, dx, dy, wfx, sfx, warpFlagDONTKILLMUSIC, 0);
20752 return true;
20753 }
20754
20755 case MSGC_SETSCREEND:
20756 {
20757 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20758 int32_t screen = grab_next_argument();
20759 int32_t reg = grab_next_argument();
20760 int32_t val = grab_next_argument();
20761 FFCore.set_screen_d(screen + dmap, reg, val);
20762 return true;
20763 }
20764 case MSGC_TAKEITEM:
20765 {
20766 int32_t itemID = grab_next_argument();
20767 if ( FFCore.doscript(ScriptType::Item, itemID) )
20768 {
20769 FFCore.doscript(ScriptType::Item, itemID) = 4; //Val of 4 means 'clear stack and quit'
20770 }
20771 takeitem(itemID);
20772 if ( game->forced_bwpn == itemID )
20773 {
20774 game->forced_bwpn = -1;
20775 } //not else if! -Z
20776 if ( game->forced_awpn == itemID )
20777 {
20778 game->forced_awpn = -1;
20779 }
20780 if ( game->forced_xwpn == itemID )
20781 {
20782 game->forced_xwpn = -1;
20783 } //not else if! -Z
20784 if ( game->forced_ywpn == itemID )
20785 {
20786 game->forced_ywpn = -1;
20787 }
20788 verifyBothWeapons();
20789 return true;
20790 }
20791
20792 case MSGC_SFX:
20793 {
20794 10 sfx((int32_t)grab_next_argument(),128);
20795 10 return true;
20796 }
20797
20798 case MSGC_MIDI:
20799 {
20800 int32_t music = (int32_t)(grab_next_argument());
20801
20802 if(music==0)
20803 music_stop();
20804 else
20805 jukebox(music+(ZC_MIDI_COUNT-1));
20806
20807 return true;
20808 }
20809
20810 case MSGC_NAME:
20811 {
20812 doing_name_insert = true;
20813 sprintf(namebuf, "%s", game->get_name());
20814 nameptr = namebuf;
20815 return true;
20816 }
20817
20818 case MSGC_FONT:
20819 {
20820 int fontid = grab_next_argument();
20821 int oh = text_height(msgfont);
20822 msgfont = get_zc_font(fontid);
20823 int nh = text_height(msgfont);
20824 int mh = std::max(oh,nh);
20825 if(mh > ssc_tile_hei_buf)
20826 ssc_tile_hei_buf = mh;
20827 return true;
20828 }
20829 case MSGC_RUN_FRZ_GENSCR:
20830 {
20831 word scr_id = grab_next_argument();
20832 bool force_redraw = grab_next_argument()!=0;
20833 if(force_redraw)
20834 {
20835 update_msgstr();
20836 draw_screen(tmpscr);
20837 }
20838 FFCore.runGenericFrozenEngine(scr_id);
20839 return true;
20840 }
20841 case MSGC_DRAWTILE:
20842 {
20843 int32_t tl = grab_next_argument();
20844 int32_t cs = grab_next_argument();
20845 int32_t t_wid = grab_next_argument();
20846 int32_t t_hei = grab_next_argument();
20847 int32_t fl = grab_next_argument();
20848
20849 if(cursor_x+MsgStrings[msgstr].hspace + t_wid > msg_w-msg_margins[right])
20850 {
20851 ssc_tile_hei = ssc_tile_hei_buf;
20852 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20853 ssc_tile_hei_buf = -1;
20854 cursor_y += thei + MsgStrings[msgstr].vspace;
20855 if(bottom_margin_clip()) return true;
20856 cursor_x=msg_margins[left];
20857 }
20858
20859 overtileblock16(msg_txt_bmp_buf, tl, cursor_x, cursor_y, (int32_t)ceil(t_wid/16.0), (int32_t)ceil(t_hei/16.0), cs, fl);
20860 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, t_hei);
20861 cursor_x += MsgStrings[msgstr].hspace + t_wid;
20862 return true;
20863 }
20864
20865 case MSGC_GOTOIFRAND:
20866 {
20867 int32_t odds = (int32_t)(grab_next_argument());
20868
20869 if(!odds || !(zc_oldrand()%odds))
20870 goto switched;
20871
20872 (void)grab_next_argument();
20873 return true;
20874 }
20875
20876 case MSGC_GOTOIFGLOBAL:
20877 {
20878 int32_t arg = (int32_t)grab_next_argument();
20879 int32_t d = zc_min(7,arg);
20880 int32_t s = ((get_currdmap())<<7) + get_currscr()-(DMaps[get_currdmap()].type==dmOVERW ? 0 : DMaps[get_currdmap()].xoff);
20881 arg = (int32_t)grab_next_argument();
20882
20883 if(game->screen_d[s][d] >= arg)
20884 goto switched;
20885
20886 (void)grab_next_argument();
20887 return true;
20888 }
20889
20890 case MSGC_CHANGEPORTRAIT:
20891 {
20892 return true; //not implemented
20893 }
20894
20895 case MSGC_GOTOIFCREEND:
20896 {
20897 int32_t dmap = (grab_next_argument()<<7); //dmap and screen may be transposed here.
20898 int32_t screen = grab_next_argument();
20899 int32_t reg = grab_next_argument();
20900 int32_t val = grab_next_argument();
20901 //int32_t nxtstr = grab_next_argument();
20902 if ( FFCore.get_screen_d(screen + dmap, reg) >= val )
20903 {
20904 goto switched;
20905 }
20906 (void)grab_next_argument();
20907 return true;
20908 }
20909
20910 case MSGC_GOTOIF:
20911 {
20912 int32_t it = (int32_t)grab_next_argument();
20913
20914 if(unsigned(it)<MAXITEMS && game->item[it])
20915 goto switched;
20916
20917 (void)grab_next_argument();
20918 return true;
20919 }
20920
20921 case MSGC_GOTOIFCTR:
20922 {
20923 if(game->get_counter(grab_next_argument())>=grab_next_argument())
20924 goto switched;
20925
20926 (void)grab_next_argument();
20927 return true;
20928 }
20929
20930 case MSGC_GOTOIFCTRPC:
20931 {
20932 int32_t counter = grab_next_argument();
20933 int32_t amount = (int32_t)(((grab_next_argument())/100)*game->get_maxcounter(counter));
20934
20935 if(game->get_counter(counter)>=amount)
20936 goto switched;
20937
20938 (void)grab_next_argument();
20939 return true;
20940 }
20941
20942 case MSGC_GOTOIFTRICOUNT:
20943 {
20944 if(TriforceCount() >= (int32_t)(grab_next_argument()))
20945 goto switched;
20946
20947 (void)grab_next_argument();
20948 return true;
20949 }
20950
20951 case MSGC_GOTOIFTRI:
20952 {
20953 int32_t lev = (int32_t)(grab_next_argument());
20954
20955 if(lev<MAXLEVELS && game->lvlitems[lev]&liTRIFORCE)
20956 goto switched;
20957
20958 (void)grab_next_argument();
20959 return true;
20960 }
20961
20962 case MSGC_SETUPMENU:
20963 {
20964 msg_menu_data[MNU_CURSOR_TILE] = grab_next_argument();
20965 msg_menu_data[MNU_CURSOR_CSET] = grab_next_argument();
20966 msg_menu_data[MNU_CURSOR_WID] = grab_next_argument();
20967 msg_menu_data[MNU_CURSOR_HEI] = grab_next_argument();
20968 msg_menu_data[MNU_CURSOR_FLIP] = grab_next_argument();
20969 return true;
20970 }
20971
20972 case MSGC_MENUCHOICE:
20973 {
20974 int32_t pos = grab_next_argument();
20975 int32_t upos = grab_next_argument();
20976 int32_t dpos = grab_next_argument();
20977 int32_t lpos = grab_next_argument();
20978 int32_t rpos = grab_next_argument();
20979 if(cursor_x+MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID] > msg_w-msg_margins[right])
20980 {
20981 ssc_tile_hei = ssc_tile_hei_buf;
20982 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
20983 ssc_tile_hei_buf = -1;
20984 cursor_y += thei + MsgStrings[msgstr].vspace;
20985 if(bottom_margin_clip()) break;
20986 cursor_x=msg_margins[left];
20987 }
20988
20989 menu_options[pos] = menu_choice(cursor_x, cursor_y, pos,
20990 upos, dpos, lpos, rpos);
20991
20992 ssc_tile_hei_buf = zc_max(ssc_tile_hei_buf, msg_menu_data[MNU_CURSOR_HEI]);
20993 cursor_x += MsgStrings[msgstr].hspace + msg_menu_data[MNU_CURSOR_WID];
20994 return true;
20995 }
20996
20997 case MSGC_RUNMENU:
20998 {
20999 msg_menu_data[MNU_CHOSEN] = 0;
21000 msg_menu_data[MNU_CAN_CONFIRM] = 0;
21001 if(menu_options.size() < 1)
21002 return true;
21003 do_run_menu = true;
21004 return true;
21005 }
21006
21007 case MSGC_GOTOMENUCHOICE:
21008 {
21009 int32_t choice = grab_next_argument();
21010 if(msg_menu_data[MNU_CHOSEN] == choice)
21011 goto switched;
21012 (void)grab_next_argument();
21013 return true;
21014 }
21015
21016 case MSGC_ENDSTRING:
21017 {
21018 do_end_str = true;
21019 return true;
21020 }
21021 case MSGC_WAIT_ADVANCE:
21022 {
21023 wait_advance = true;
21024 linkedmsgclk = 51;
21025 return true;
21026 }
21027 case MSGC_TRIGSECRETS:
21028 {
21029 bool perm = (bool)grab_next_argument();
21030 hidden_entrance(0, true, false, -8);
21031 if(perm)
21032 setmapflag(mSECRET);
21033 return true;
21034 }
21035 case MSGC_SETSCREENSTATE:
21036 {
21037 int32_t flag = int32_t(grab_next_argument());
21038 if(unsigned(flag)>=mMAXIND)
21039 {
21040 Z_error("SCC 133: Flag %d is invalid\n", flag);
21041 return true;
21042 }
21043 bool state = bool(grab_next_argument());
21044 if(state)
21045 setmapflag(1<<flag);
21046 else
21047 unsetmapflag(1<<flag,true);
21048 return true;
21049 }
21050 case MSGC_SETSCREENSTATER:
21051 {
21052 int32_t map = (int32_t)grab_next_argument();
21053 int32_t scrid = (int32_t)grab_next_argument();
21054 if(map < 1 || map > map_count)
21055 {
21056 Z_error("SCC 134: Map %d is invalid\n", map);
21057 return true;
21058 }
21059 if(unsigned(scrid)>=0x80)
21060 {
21061 Z_error("SCC 134: Screen %d is invalid\n", scrid);
21062 return true;
21063 }
21064
21065 int32_t flag = int32_t(grab_next_argument());
21066 if(unsigned(flag)>=mMAXIND)
21067 {
21068 Z_error("SCC 134: Flag %d is invalid\n", flag);
21069 return true;
21070 }
21071 bool state = bool(grab_next_argument());
21072 if(state)
21073 setmapflag(mapind(map,scrid),1<<flag);
21074 else
21075 unsetmapflag(mapind(map,scrid),1<<flag,true);
21076 return true;
21077 }
21078 switched:
21079 int32_t lev = (int32_t)(grab_next_argument());
21080 if(lev && get_qr(qr_SCC_GOTO_RESPECTS_CONTFLAG)
21081 && (MsgStrings[lev].stringflags & STRINGFLAG_CONT))
21082 {
21083 msgstr=lev;
21084 msgpos=msgptr=0;
21085 msgfont=setmsgfont();
21086 }
21087 else
21088 {
21089 donewmsg(lev);
21090 ssc_tile_hei_buf = -1;
21091 }
21092 msgptr--; // To counteract it being incremented after this routine is called.
21093 putprices(false);
21094 return true;
21095 }
21096
21097 97457 return false;
21098 98407 }
21099
21100 // Wraps the message string... probably.
21101 95975 void wrapmsgstr(char *s3)
21102 {
21103 95975 int32_t j=0;
21104
21105
2/2
✓ Branch 0 taken 9679 times.
✓ Branch 1 taken 86296 times.
95975 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21106 {
21107
2/2
✓ Branch 0 taken 2081 times.
✓ Branch 1 taken 7598 times.
9679 if(msgspace)
21108 {
21109 2081 char c = MsgStrings[msgstr].s[msgptr];
21110
4/6
✓ Branch 0 taken 1786 times.
✓ Branch 1 taken 295 times.
✓ Branch 2 taken 1786 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1786 times.
✗ Branch 5 not taken.
2081 if(c != ' ' && c >= 32 && c <= 126)
21111 {
21112
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 9806 times.
✓ Branch 2 taken 8026 times.
✓ Branch 3 taken 1786 times.
9812 for(int32_t k=0; MsgStrings[msgstr].s[msgptr+k] && MsgStrings[msgstr].s[msgptr+k] != ' '; k++)
21113 {
21114
3/4
✓ Branch 0 taken 7734 times.
✓ Branch 1 taken 292 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7734 times.
8026 if(MsgStrings[msgstr].s[msgptr+k] >= 32 && MsgStrings[msgstr].s[msgptr+k] <= 126) s3[j++] = MsgStrings[msgstr].s[msgptr+k];
21115 8026 }
21116
21117 1786 s3[j] = 0;
21118 1786 msgspace = false;
21119 1786 }
21120 else
21121 {
21122 295 s3[0] = c;
21123 295 s3[1] = 0;
21124 }
21125 2081 }
21126 else
21127 {
21128 7598 s3[0] = MsgStrings[msgstr].s[msgptr];
21129 7598 s3[1] = 0;
21130
21131
2/2
✓ Branch 0 taken 5948 times.
✓ Branch 1 taken 1650 times.
7598 if(s3[0] == ' ') msgspace=true;
21132 }
21133 9679 }
21134 else
21135 {
21136 86296 s3[0] = MsgStrings[msgstr].s[msgptr];
21137 86296 s3[1] = 0;
21138 }
21139 95975 }
21140
21141 // Returns true if the pointer is at a string's
21142 // null terminator or a trailing space
21143 251744 bool atend(char const* str)
21144 {
21145 251744 int32_t i=0;
21146
21147
2/2
✓ Branch 0 taken 1563482 times.
✓ Branch 1 taken 251744 times.
1815226 while(str[i]==' ')
21148 1563482 i++;
21149
21150 251744 return str[i]=='\0';
21151 }
21152
21153 7285588 void putmsg()
21154 {
21155 7285588 bool oldmargin = get_qr(qr_OLD_STRING_EDITOR_MARGINS)!=0;
21156
2/2
✓ Branch 0 taken 259878 times.
✓ Branch 1 taken 7025710 times.
7285588 if(!msgorig) msgorig=msgstr;
21157
21158
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7285588 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7285588 if(wait_advance && linkedmsgclk < 1)
21159 linkedmsgclk = 1;
21160
2/2
✓ Branch 0 taken 7189451 times.
✓ Branch 1 taken 96137 times.
7285588 if(linkedmsgclk>0)
21161 {
21162
2/2
✓ Branch 0 taken 45486 times.
✓ Branch 1 taken 50651 times.
96137 if(linkedmsgclk==1)
21163 {
21164
5/6
✓ Branch 0 taken 45486 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44557 times.
✓ Branch 3 taken 929 times.
✓ Branch 4 taken 84 times.
✓ Branch 5 taken 44473 times.
45486 if(do_end_str||cAbtn()||cBbtn())
21165 {
21166 1013 do_end_str = false;
21167 1013 linkedmsgclk = 0;
21168
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1013 times.
1013 if(wait_advance)
21169 {
21170 wait_advance = false;
21171 }
21172 else
21173 {
21174 1013 msgstr=MsgStrings[msgstr].nextstring;
21175 1013 ssc_tile_hei_buf = -1;
21176
3/4
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 836 times.
✓ Branch 2 taken 177 times.
✗ Branch 3 not taken.
1013 if(!msgstr && enqueued_str)
21177 {
21178 msgstr = enqueued_str;
21179 enqueued_str = 0;
21180 }
21181
2/2
✓ Branch 0 taken 836 times.
✓ Branch 1 taken 177 times.
1013 if(!msgstr)
21182 {
21183 177 msgfont=get_zc_font(font_zfont);
21184
21185
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177 times.
177 if(tmpscr->room!=rGRUMBLE)
21186 177 blockpath=false;
21187
21188 177 dismissmsg();
21189 177 goto disappear;
21190 }
21191
21192 836 donewmsg(msgstr);
21193 836 putprices(false);
21194 }
21195 836 }
21196 45309 }
21197 else
21198 {
21199 50651 --linkedmsgclk;
21200 }
21201 95960 }
21202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7285411 times.
7285411 if(wait_advance) return; //Waiting for buttonpress
21203
21204
9/10
✓ Branch 0 taken 7285317 times.
✓ Branch 1 taken 94 times.
✓ Branch 2 taken 258769 times.
✓ Branch 3 taken 7026548 times.
✓ Branch 4 taken 125265 times.
✓ Branch 5 taken 133504 times.
✓ Branch 6 taken 64562 times.
✓ Branch 7 taken 60703 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 64562 times.
7285411 if(!do_run_menu && (!msgstr || msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip()))
21205 {
21206
2/2
✓ Branch 0 taken 194207 times.
✓ Branch 1 taken 7026548 times.
7220755 if(!msgstr)
21207 7026548 msgorig=0;
21208
21209 7220755 msg_active = false;
21210 7220755 return;
21211 }
21212
21213 64656 msg_onscreen = true; // Now the message is onscreen (see donewmsg()).
21214
21215 char s3[145];
21216 int32_t tlength;
21217
21218 // Bypass the string with the B button!
21219
4/4
✓ Branch 0 taken 331 times.
✓ Branch 1 taken 64325 times.
✓ Branch 2 taken 961 times.
✓ Branch 3 taken 63364 times.
64656 if(((cBbtn())&&(get_qr(qr_ALLOWMSGBYPASS))) || msgspeed==0)
21220 {
21221 //finish writing out the string
21222
4/4
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 77095 times.
✓ Branch 2 taken 1198 times.
✓ Branch 3 taken 75989 times.
77281 while(msgptr<MsgStrings[msgstr].s.size() && !atend(MsgStrings[msgstr].s.c_str()+msgptr))
21223 {
21224
4/6
✓ Branch 0 taken 17002 times.
✓ Branch 1 taken 58987 times.
✓ Branch 2 taken 17002 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 17002 times.
✗ Branch 5 not taken.
75989 if(msgspeed && !(cBbtn() && get_qr(qr_ALLOWMSGBYPASS)))
21225 goto breakout; // break out if message speed was changed to non-zero
21226
4/6
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 75989 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 75753 times.
75989 else if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21227 {
21228
1/2
✓ Branch 0 taken 75753 times.
✗ Branch 1 not taken.
75753 if(bottom_margin_clip())
21229 break;
21230
21231 75753 wrapmsgstr(s3);
21232
21233
2/2
✓ Branch 0 taken 20120 times.
✓ Branch 1 taken 55633 times.
75753 if(MsgStrings[msgstr].s[msgptr]==' ')
21234 {
21235 20120 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21236
21237
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 1347 times.
21510 if(cursor_x+tlength > (msg_w-msg_margins[right])
21238
5/6
✓ Branch 0 taken 1390 times.
✓ Branch 1 taken 18730 times.
✓ Branch 2 taken 1390 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1304 times.
✓ Branch 5 taken 43 times.
20120 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21239 43 ? true : strcmp(s3," ")!=0))
21240 {
21241 1347 ssc_tile_hei = ssc_tile_hei_buf;
21242
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21243 1347 ssc_tile_hei_buf = -1;
21244 1347 cursor_y += thei + MsgStrings[msgstr].vspace;
21245
1/2
✓ Branch 0 taken 1347 times.
✗ Branch 1 not taken.
1347 if(bottom_margin_clip()) break;
21246 1347 cursor_x=msg_margins[left];
21247 1347 }
21248
21249 20120 char buf[2] = {0};
21250 20120 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21251
21252 20120 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21253
21254 20120 cursor_x+=tlength;
21255 20120 }
21256 else
21257 {
21258 55633 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21259
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 533 times.
56334 if(cursor_x+tlength > (msg_w-msg_margins[right])
21260
5/6
✓ Branch 0 taken 744 times.
✓ Branch 1 taken 54889 times.
✓ Branch 2 taken 701 times.
✓ Branch 3 taken 43 times.
✓ Branch 4 taken 576 times.
✗ Branch 5 not taken.
55633 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21261 168 ? true : strcmp(s3," ")!=0))
21262 {
21263 744 ssc_tile_hei = ssc_tile_hei_buf;
21264
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21265 744 ssc_tile_hei_buf = -1;
21266 744 cursor_y += thei + MsgStrings[msgstr].vspace;
21267
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(bottom_margin_clip()) break;
21268 744 cursor_x=msg_margins[left];
21269 744 }
21270
21271 55633 sfx(MsgStrings[msgstr].sfx);
21272
21273 55633 char buf[2] = {0};
21274 55633 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21275
21276 55633 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21277
21278 55633 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21279 55633 cursor_x += MsgStrings[msgstr].hspace;
21280 }
21281
21282 75753 msgpos++;
21283 75753 }
21284
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_run_menu)
21285 {
21286 if(runMenuCursor())
21287 {
21288 do_run_menu = false;
21289 }
21290 else break;
21291 }
21292
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(doing_name_insert)
21293 {
21294 if(*nameptr)
21295 {
21296 if(bottom_margin_clip())
21297 break;
21298
21299 char s3[9] = {0};
21300
21301 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21302 {
21303 strcpy(s3, nameptr);
21304 }
21305 else
21306 {
21307 s3[0] = *nameptr;
21308 s3[1] = 0;
21309 }
21310
21311 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21312
21313 if(cursor_x+tlength > (msg_w-msg_margins[right])
21314 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21315 ? true : strcmp(s3," ")!=0))
21316 {
21317 ssc_tile_hei = ssc_tile_hei_buf;
21318 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21319 ssc_tile_hei_buf = -1;
21320 cursor_y += thei + MsgStrings[msgstr].vspace;
21321 if(bottom_margin_clip()) break;
21322 cursor_x=msg_margins[left];
21323 }
21324
21325 sfx(MsgStrings[msgstr].sfx);
21326
21327 char buf[2] = {0};
21328 sprintf(buf,"%c",*nameptr);
21329
21330 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21331
21332 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21333 cursor_x += MsgStrings[msgstr].hspace;
21334 ++nameptr;
21335 continue; //don't advance the msgptr, as the next char in it was not processed!
21336 }
21337 else doing_name_insert = false;
21338 }
21339 75989 ++msgptr;
21340
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(do_end_str)
21341 goto strendcheck;
21342
1/2
✓ Branch 0 taken 75989 times.
✗ Branch 1 not taken.
75989 if(wait_advance)
21343 return;
21344
2/2
✓ Branch 0 taken 74810 times.
✓ Branch 1 taken 1179 times.
75989 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21345 {
21346
2/2
✓ Branch 0 taken 403 times.
✓ Branch 1 taken 776 times.
1179 if(MsgStrings[msgstr].nextstring)
21347 {
21348
1/2
✓ Branch 0 taken 776 times.
✗ Branch 1 not taken.
776 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21349 {
21350 msgstr=MsgStrings[msgstr].nextstring;
21351 msgpos=msgptr=0;
21352 msgfont=setmsgfont();
21353 }
21354 776 }
21355 1179 }
21356 }
21357
21358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1198 times.
1198 if (!do_run_menu)
21359 {
21360 1198 msgclk = 72;
21361 1198 msgpos = 10000;
21362 1198 }
21363 1198 }
21364 else
21365 63364 {
21366 breakout:
21367 63364 word tempspeed = msgspeed;
21368
1/2
✓ Branch 0 taken 63364 times.
✗ Branch 1 not taken.
63364 if (do_run_menu)
21369 tempspeed = 0;
21370
6/6
✓ Branch 0 taken 52672 times.
✓ Branch 1 taken 10692 times.
✓ Branch 2 taken 15055 times.
✓ Branch 3 taken 37617 times.
✓ Branch 4 taken 10249 times.
✓ Branch 5 taken 4806 times.
63364 if(((msgclk++)%(tempspeed+1)<tempspeed)&&((!cAbtn())||(!get_qr(qr_ALLOWFASTMSG))))
21371 42423 return;
21372 }
21373
21374 // Start writing the string
21375
2/2
✓ Branch 0 taken 21530 times.
✓ Branch 1 taken 609 times.
22748 if(msgptr == 0)
21376 {
21377
2/2
✓ Branch 0 taken 609 times.
✓ Branch 1 taken 2415 times.
3024 while(MsgStrings[msgstr].s[msgptr]==' ')
21378 {
21379 2415 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21380
21381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41 times.
2456 if(cursor_x+tlength > (msg_w-msg_margins[right])
21382
4/6
✓ Branch 0 taken 2374 times.
✓ Branch 1 taken 41 times.
✓ Branch 2 taken 41 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✗ Branch 5 not taken.
2415 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21383 ? 1 : strcmp(s3," ")!=0))
21384 {
21385 41 ssc_tile_hei = ssc_tile_hei_buf;
21386
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21387 41 ssc_tile_hei_buf = -1;
21388 41 cursor_y += thei + MsgStrings[msgstr].vspace;
21389
1/2
✓ Branch 0 taken 41 times.
✗ Branch 1 not taken.
41 if(bottom_margin_clip()) break;
21390 41 cursor_x=msg_margins[left];
21391 41 }
21392
21393 2415 cursor_x+=tlength;
21394 2415 ++msgptr;
21395 2415 ++msgpos;
21396
21397 // The "Continue From Previous" feature
21398
2/2
✓ Branch 0 taken 1047 times.
✓ Branch 1 taken 1368 times.
2415 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21399 {
21400
1/2
✓ Branch 0 taken 1368 times.
✗ Branch 1 not taken.
1368 if(MsgStrings[msgstr].nextstring)
21401 {
21402 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21403 {
21404 msgstr=MsgStrings[msgstr].nextstring;
21405 msgpos=msgptr=0;
21406 msgfont=setmsgfont();
21407 }
21408 }
21409 1368 }
21410 }
21411 609 }
21412
21413 reparsesinglechar:
21414 // Continue printing the string!
21415
3/4
✓ Branch 0 taken 20335 times.
✓ Branch 1 taken 1804 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20335 times.
42474 if(!atend(MsgStrings[msgstr].s.c_str()+msgptr) && !bottom_margin_clip())
21416 {
21417
4/6
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20335 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113 times.
✓ Branch 5 taken 20222 times.
20335 if(!do_run_menu && !doing_name_insert && !parsemsgcode())
21418 {
21419 20222 wrapmsgstr(s3);
21420
21421 20222 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21422
21423
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 236 times.
20478 if(cursor_x+tlength > (msg_w-msg_margins[right])
21424
6/6
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 19962 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 236 times.
✓ Branch 5 taken 4 times.
20222 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21425 20 ? true : strcmp(s3," ")!=0))
21426 {
21427 256 ssc_tile_hei = ssc_tile_hei_buf;
21428
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21429 256 ssc_tile_hei_buf = -1;
21430 256 cursor_y += thei + MsgStrings[msgstr].vspace;
21431
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(bottom_margin_clip()) goto strendcheck;
21432 256 cursor_x=msg_margins[left];
21433 //if(space) s3[0]=0;
21434 256 }
21435
21436 20222 sfx(MsgStrings[msgstr].sfx);
21437
21438 20222 char buf[2] = {0};
21439 20222 sprintf(buf,"%c",MsgStrings[msgstr].s[msgptr]);
21440
21441 20222 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21442
21443 20222 cursor_x += msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]);
21444 20222 cursor_x += MsgStrings[msgstr].hspace;
21445 20222 msgpos++;
21446 20222 }
21447
1/2
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
20335 if(do_end_str)
21448 goto strendcheck;
21449
1/2
✓ Branch 0 taken 20335 times.
✗ Branch 1 not taken.
20335 if(wait_advance)
21450 {
21451 ++msgptr;
21452 return;
21453 }
21454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20335 times.
20335 else if(do_run_menu)
21455 {
21456 if(runMenuCursor())
21457 {
21458 do_run_menu = false;
21459 ++msgptr;
21460 goto reparsesinglechar;
21461 }
21462 }
21463
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 20335 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20335 else if(doing_name_insert && *nameptr)
21464 {
21465 char s3[9] = {0};
21466
21467 if(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP)
21468 {
21469 strcpy(s3, nameptr);
21470 }
21471 else
21472 {
21473 s3[0] = *nameptr;
21474 s3[1] = 0;
21475 }
21476
21477 tlength = text_length(msgfont, s3) + ((int32_t)strlen(s3)*MsgStrings[msgstr].hspace);
21478
21479 if(cursor_x+tlength > (msg_w-msg_margins[right])
21480 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21481 ? true : strcmp(s3," ")!=0))
21482 {
21483 ssc_tile_hei = ssc_tile_hei_buf;
21484 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21485 ssc_tile_hei_buf = -1;
21486 cursor_y += thei + MsgStrings[msgstr].vspace;
21487 if(bottom_margin_clip()) goto strendcheck;
21488 cursor_x=msg_margins[left];
21489 }
21490
21491 sfx(MsgStrings[msgstr].sfx);
21492
21493 char buf[2] = {0};
21494 sprintf(buf,"%c",*nameptr);
21495
21496 textout_styled_aligned_ex(msg_txt_bmp_buf,msgfont,buf,cursor_x,cursor_y,msg_shdtype,sstaLEFT,msgcolour,msg_shdcol,-1);
21497
21498 cursor_x += msgfont->vtable->char_length(msgfont, *nameptr);
21499 cursor_x += MsgStrings[msgstr].hspace;
21500 ++nameptr;
21501 }
21502 else
21503 {
21504 20335 doing_name_insert = false;
21505 20335 msgptr++;
21506
21507
2/2
✓ Branch 0 taken 19832 times.
✓ Branch 1 taken 503 times.
20335 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21508 {
21509
2/2
✓ Branch 0 taken 442 times.
✓ Branch 1 taken 61 times.
503 if(MsgStrings[msgstr].nextstring)
21510 {
21511
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21512 {
21513 msgstr=MsgStrings[msgstr].nextstring;
21514 msgpos=msgptr=0;
21515 msgfont=setmsgfont();
21516 }
21517 61 }
21518 503 }
21519
21520
2/2
✓ Branch 0 taken 2981 times.
✓ Branch 1 taken 1011 times.
24327 if(MsgStrings[msgstr].s.size() > unsigned(msgptr+1)
21521
2/2
✓ Branch 0 taken 20288 times.
✓ Branch 1 taken 47 times.
20335 && (MsgStrings[msgstr].s[msgptr]==' ')
21522
2/2
✓ Branch 0 taken 3992 times.
✓ Branch 1 taken 16296 times.
20288 && (MsgStrings[msgstr].s[msgptr+1]==' '))
21523 {
21524
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 33320 times.
34331 while(MsgStrings[msgstr].s[msgptr]==' ')
21525 {
21526 33320 msgspace = true;
21527 33320 tlength = msgfont->vtable->char_length(msgfont, MsgStrings[msgstr].s[msgptr]) + MsgStrings[msgstr].hspace;
21528
21529
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1440 times.
34783 if(cursor_x+tlength > (msg_w-msg_margins[right])
21530
4/6
✓ Branch 0 taken 1463 times.
✓ Branch 1 taken 31857 times.
✓ Branch 2 taken 1463 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1440 times.
✗ Branch 5 not taken.
33320 && ((cursor_x > (msg_w-msg_margins[right]) || !(MsgStrings[msgstr].stringflags & STRINGFLAG_WRAP))
21531 23 ? true : strcmp(s3," ")!=0))
21532 {
21533 1463 ssc_tile_hei = ssc_tile_hei_buf;
21534
1/2
✓ Branch 0 taken 1463 times.
✗ Branch 1 not taken.
1463 int32_t thei = zc_max(ssc_tile_hei, text_height(msgfont));
21535 1463 ssc_tile_hei_buf = -1;
21536 1463 cursor_y += thei + MsgStrings[msgstr].vspace;
21537
1/2
✓ Branch 0 taken 1463 times.
✗ Branch 1 not taken.
1463 if(bottom_margin_clip()) break;
21538 1463 cursor_x=msg_margins[left];
21539 1463 }
21540
21541 33320 cursor_x+=tlength;
21542 33320 ++msgpos;
21543 33320 ++msgptr;
21544
21545
2/2
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 30070 times.
33320 if(atend(MsgStrings[msgstr].s.c_str()+msgptr))
21546 {
21547
2/2
✓ Branch 0 taken 25984 times.
✓ Branch 1 taken 4086 times.
30070 if(MsgStrings[msgstr].nextstring)
21548 {
21549
1/2
✓ Branch 0 taken 4086 times.
✗ Branch 1 not taken.
4086 if(MsgStrings[MsgStrings[msgstr].nextstring].stringflags & STRINGFLAG_CONT)
21550 {
21551 msgstr=MsgStrings[msgstr].nextstring;
21552 msgpos=msgptr=0;
21553 msgfont=setmsgfont();
21554 }
21555 4086 }
21556 30070 }
21557 }
21558 1011 }
21559 }
21560 20335 }
21561 strendcheck:
21562 // Done printing the string
21563
10/14
✓ Branch 0 taken 22139 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22139 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 22139 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 20941 times.
✓ Branch 7 taken 1198 times.
✓ Branch 8 taken 20451 times.
✓ Branch 9 taken 490 times.
✓ Branch 10 taken 20451 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20056 times.
✓ Branch 13 taken 2083 times.
22139 if(do_end_str || !doing_name_insert && !do_run_menu && (msgpos>=10000 || msgptr>=MsgStrings[msgstr].s.size() || bottom_margin_clip() || atend(MsgStrings[msgstr].s.c_str()+msgptr)) && !linkedmsgclk)
21564 {
21565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2083 times.
2083 if(!do_end_str)
21566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2083 times.
2083 while(parsemsgcode()); // Finish remaining control codes
21567
21568 // Go to next string, or make it disappear by going to string 0.
21569
5/6
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 837 times.
✓ Branch 2 taken 1069 times.
✓ Branch 3 taken 177 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1069 times.
2083 if(MsgStrings[msgstr].nextstring!=0 || get_qr(qr_MSGDISAPPEAR) || enqueued_str)
21570 {
21571 1014 linkedmsgclk=do_end_str?1:51;
21572 1014 }
21573
21574
2/2
✓ Branch 0 taken 1246 times.
✓ Branch 1 taken 837 times.
2083 if(MsgStrings[msgstr].nextstring==0)
21575 {
21576
2/2
✓ Branch 0 taken 177 times.
✓ Branch 1 taken 1069 times.
1246 if(!get_qr(qr_MSGDISAPPEAR))
21577 1069 {
21578 disappear:
21579 1246 msg_active = false;
21580 1246 Hero.finishedmsg();
21581 1246 }
21582
21583
2/2
✓ Branch 0 taken 1411 times.
✓ Branch 1 taken 12 times.
1423 if(repaircharge)
21584 {
21585 // if (get_qr(qr_REPAIRFIX)) {
21586 // fixed_door=true;
21587 // }
21588 12 game->change_drupy(-tmpscr[currscr<128?0:1].catchall);
21589 12 repaircharge = 0;
21590 12 }
21591
21592
2/2
✓ Branch 0 taken 1422 times.
✓ Branch 1 taken 1 times.
1423 if(adjustmagic)
21593 {
21594
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(get_qr(qr_OLD_HALF_MAGIC))
21595 {
21596
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(game->get_magicdrainrate())
21597 1 game->set_magicdrainrate(1);
21598 1 }
21599 else if(game->get_magicdrainrate() > 1)
21600 {
21601 game->set_magicdrainrate(game->get_magicdrainrate()/2);
21602 }
21603 1 adjustmagic = false;
21604 1 sfx(WAV_SCALE);
21605
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21606 1 }
21607
21608
2/2
✓ Branch 0 taken 1421 times.
✓ Branch 1 taken 2 times.
1423 if(learnslash)
21609 {
21610 2 game->set_canslash(1);
21611 2 learnslash = false;
21612 2 sfx(WAV_SCALE);
21613
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 setmapflag((currscr < 128 && get_qr(qr_ITEMPICKUPSETSBELOW)) ? mITEM : mSPECIALITEM);
21614 2 }
21615 1423 }
21616 2260 }
21617 7285494 }
21618
21619 45302 int32_t message_more_y()
21620 {
21621 //Is the flag ticked, do we really want a message more y larger than 160?
21622
5/6
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 45288 times.
✓ Branch 2 taken 45302 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 45288 times.
✓ Branch 5 taken 14 times.
45302 int32_t msgy=zc_min((zinit.msg_more_is_offset==0)?zinit.msg_more_y:zinit.msg_more_y+MsgStrings[msgstr].y ,160);
21623 45302 msgy+=playing_field_offset;
21624 45302 return msgy;
21625 }
21626
21627 /*** Collision detection & handling ***/
21628
21629 7262199 void clear_script_one_frame_conditions()
21630 {
21631
2/2
✓ Branch 0 taken 21645616 times.
✓ Branch 1 taken 7262199 times.
28907815 for(int32_t j=0; j<guys.Count(); j++)
21632 {
21633 21645616 enemy *e = (enemy*)guys.spr(j);
21634
2/2
✓ Branch 0 taken 367975472 times.
✓ Branch 1 taken 21645616 times.
389621088 for ( int32_t q = 0; q < NUM_HIT_TYPES_USED; q++ ) e->hitby[q] = 0;
21635 21645616 }
21636 7262199 }
21637
21638 7262051 void check_collisions()
21639 {
21640
2/2
✓ Branch 0 taken 2980512 times.
✓ Branch 1 taken 7262051 times.
10242563 for(int32_t i=0; i<Lwpns.Count(); i++)
21641 {
21642 2980512 weapon *w = (weapon*)Lwpns.spr(i);
21643
21644
8/8
✓ Branch 0 taken 2516103 times.
✓ Branch 1 taken 464409 times.
✓ Branch 2 taken 2107862 times.
✓ Branch 3 taken 408241 times.
✓ Branch 4 taken 2086549 times.
✓ Branch 5 taken 21313 times.
✓ Branch 6 taken 13640 times.
✓ Branch 7 taken 2072909 times.
2980512 if(!(w->Dead()) && w->id!=wSword && w->id!=wHammer && w->id!=wWand)
21645 {
21646
2/2
✓ Branch 0 taken 2062226 times.
✓ Branch 1 taken 7445354 times.
9507580 for(int32_t j=0; j<guys.Count(); j++)
21647 {
21648 7445354 enemy *e = (enemy*)guys.spr(j);
21649
21650 7445354 bool didhit = e->hit(w);
21651
2/2
✓ Branch 0 taken 7307623 times.
✓ Branch 1 taken 137731 times.
7445354 if(didhit) //boomerangs and such that last for more than a frame can write hitby[] for more than one frame,
21652 //because this only checks `if(dying || clk<0 || hclk>0 || superman)`
21653 {
21654 // !(e->stunclk)
21655 137731 int32_t h = e->takehit(w);
21656
2/2
✓ Branch 0 taken 114502 times.
✓ Branch 1 taken 23229 times.
137731 if (h == -1)
21657 {
21658 23229 e->hitby[HIT_BY_LWEAPON] = i+1;
21659 23229 e->hitby[HIT_BY_LWEAPON_UID] = w->script_UID;
21660 23229 e->hitby[HIT_BY_LWEAPON_TYPE] = w->id;
21661
2/2
✓ Branch 0 taken 1663 times.
✓ Branch 1 taken 21566 times.
23229 if (w->parentitem > -1) e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = itemsbuf[w->parentitem].family;
21662 1663 else e->hitby[HIT_BY_LWEAPON_PARENT_FAMILY] = -1;
21663 23229 e->hitby[HIT_BY_LWEAPON_PARENT_ID] = w->parentitem;
21664 23229 e->hitby[HIT_BY_LWEAPON_ENGINE_UID] = w->getUID();
21665
21666 23229 }
21667 //we may need to handle this in special cases. -Z
21668
21669 //if h == stun or ignore
21670
21671 //if e->stun > DEFAULT_STUN -1 || !e->stun
21672 //if the enemy wasn't stunned this round -- what a bitch, as the stun value is set before we check this
21673 ///! how about: if w->dead != bounce !
21674
21675 // NOT FOR PUBLIC RELEASE
21676 /*if(h==3) //Mirror shield
21677 {
21678 if (w->id==ewFireball || w->id==wRefFireball)
21679 {
21680 w->id=wRefFireball;
21681 switch(e->dir)
21682 {
21683 case up: e->angle += (PI - e->angle) * 2.0; break;
21684 case down: e->angle = -e->angle; break;
21685 case left: e->angle += ((-PI/2) - e->angle) * 2.0; break;
21686 case right: e->angle += (( PI/2) - e->angle) * 2.0; break;
21687 // TODO: the following. -L.
21688 case l_up: break;
21689 case r_up: break;
21690 case l_down: break;
21691 case r_down: break;
21692 }
21693 }
21694 else
21695 {
21696 w->id = ((w->id==ewMagic || w->id==wRefMagic || w->id==wMagic) ? wRefMagic : wRefBeam);
21697 w->dir ^= 1;
21698 if(w->dir&2)
21699 w->flip ^= 1;
21700 else
21701 w->flip ^= 2;
21702 }
21703 w->ignoreHero=false;
21704 }
21705 else*/
21706
2/2
✓ Branch 0 taken 107377 times.
✓ Branch 1 taken 30354 times.
137731 if(h)
21707 {
21708
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 30354 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
30354 if(e->switch_hooked && w->family_class == itype_switchhook)
21709 w->onhit(false, e, -1);
21710 30354 else w->onhit(false, e, h);
21711 30354 }
21712
21713
2/2
✓ Branch 0 taken 135422 times.
✓ Branch 1 taken 2309 times.
137731 if(h==2)
21714 {
21715 2309 break;
21716 }
21717 135422 }
21718
21719
2/2
✓ Branch 0 taken 7434671 times.
✓ Branch 1 taken 8374 times.
7443045 if(w->Dead())
21720 {
21721 8374 break;
21722 }
21723 7434671 }
21724
21725 // Item flags added in 2.55:
21726 // BRang/HShot/Arrows ITEM_FLAG4 is "Pick up anything" (port of qr_BRANGPICKUP)
21727 // BRang/HShot ITEM_FLAG5 is "Drags Items" (port of qr_Z3BRANG_HSHOT)
21728 // Arrows ITEM_FLAG2 is "Picks up items" (inverse port of qr_Z3BRANG_HSHOT)
21729 // -V
21730
6/6
✓ Branch 0 taken 1760149 times.
✓ Branch 1 taken 312760 times.
✓ Branch 2 taken 1755673 times.
✓ Branch 3 taken 4476 times.
✓ Branch 4 taken 21925 times.
✓ Branch 5 taken 1733748 times.
2072909 if(w->id == wBrang || w->id == wHookshot || w->id == wArrow)
21731 {
21732 339161 int32_t itype, pitem = w->parentitem;
21733
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 312760 times.
✓ Branch 2 taken 21925 times.
✓ Branch 3 taken 4476 times.
339161 switch(w->id)
21734 {
21735 312760 case wBrang: itype = itype_brang; break;
21736 21925 case wArrow: itype = itype_arrow; break;
21737 case wHookshot:
21738 4476 itype = (w->family_class == itype_switchhook ? itype_switchhook :itype_hookshot);
21739 4476 break;
21740 }
21741
2/2
✓ Branch 0 taken 334309 times.
✓ Branch 1 taken 4852 times.
339161 if(pitem < 0) pitem = current_item_id(itype);
21742
5/6
✓ Branch 0 taken 4476 times.
✓ Branch 1 taken 334685 times.
✓ Branch 2 taken 100 times.
✓ Branch 3 taken 4376 times.
✓ Branch 4 taken 100 times.
✗ Branch 5 not taken.
339161 if(w->id == wHookshot && w->family_class == itype_switchhook && (itemsbuf[pitem].flags & ITEM_FLAG9))
21743 { //Swap with item
21744 for(int32_t j=0; j<items.Count(); j++)
21745 {
21746 if(items.spr(j)->hit(w))
21747 {
21748 item *theItem = ((item*)items.spr(j));
21749 bool priced = theItem->PriceIndex >-1;
21750 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21751 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21752 || (((itemsbuf[w->parentitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[w->parentitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21753 {
21754 if(!Hero.switchhookclk)
21755 {
21756 hooked_combopos = -1;
21757 hooked_layerbits = 0;
21758 switching_object = theItem;
21759 theItem->switch_hooked = true;
21760 w->misc = 2;
21761 w->step = 0;
21762 theItem->clk2=256;
21763 Hero.doSwitchHook(game->get_switchhookstyle());
21764 if(QMisc.miscsfx[sfxSWITCHED])
21765 sfx(QMisc.miscsfx[sfxSWITCHED],int32_t(w->x));
21766 }
21767 }
21768 }
21769 }
21770 }
21771
6/6
✓ Branch 0 taken 21925 times.
✓ Branch 1 taken 317236 times.
✓ Branch 2 taken 318320 times.
✓ Branch 3 taken 296395 times.
✓ Branch 4 taken 317236 times.
✓ Branch 5 taken 296395 times.
339161 else if((w->id==wArrow&&itemsbuf[pitem].flags & ITEM_FLAG2)||(w->id!=wArrow&&!(itemsbuf[pitem].flags & ITEM_FLAG5)))//An arrow with "Picks up items" or a BRang/HShot without "Drags items"
21772 {
21773
2/2
✓ Branch 0 taken 73578 times.
✓ Branch 1 taken 318320 times.
391898 for(int32_t j=0; j<items.Count(); j++)
21774 {
21775
2/2
✓ Branch 0 taken 69398 times.
✓ Branch 1 taken 4180 times.
73578 if(items.spr(j)->hit(w))
21776 {
21777 4180 item *theItem = ((item*)items.spr(j));
21778 4180 bool priced = theItem->PriceIndex >-1;
21779
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 4096 times.
4180 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21780
5/8
✓ Branch 0 taken 4180 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4180 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3363 times.
✓ Branch 5 taken 817 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1858 times.
6038 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21781
4/6
✓ Branch 0 taken 2675 times.
✓ Branch 1 taken 1858 times.
✓ Branch 2 taken 2675 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2675 times.
4180 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey))&& !priced)))
21782 {
21783
1/2
✓ Branch 0 taken 1505 times.
✗ Branch 1 not taken.
5221 if(itemsbuf[theItem->id].collect_script)
21784 {
21785 ZScriptVersion::RunScript(ScriptType::Item, itemsbuf[theItem->id].collect_script, theItem->id & 0xFFF);
21786 }
21787
21788 1505 Hero.checkitems(j);
21789 1505 }
21790 4180 }
21791 73578 }
21792 318320 }
21793
2/2
✓ Branch 0 taken 4872 times.
✓ Branch 1 taken 15969 times.
613631 else if(w->id!=wArrow) //A BRang/HShot with "Drags Items"
21794 {
21795
2/2
✓ Branch 0 taken 3337 times.
✓ Branch 1 taken 15969 times.
19306 for(int32_t j=0; j<items.Count(); j++)
21796 {
21797
2/2
✓ Branch 0 taken 2402 times.
✓ Branch 1 taken 935 times.
3337 if(items.spr(j)->hit(w))
21798 {
21799 935 item *theItem = ((item*)items.spr(j));
21800 935 bool priced = theItem->PriceIndex >-1;
21801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 935 times.
935 bool isKey = itemsbuf[theItem->id].family==itype_key||itemsbuf[theItem->id].family==itype_lkey;
21802
4/6
✓ Branch 0 taken 935 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 935 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 895 times.
✓ Branch 5 taken 40 times.
935 if(!theItem->fallclk && !theItem->drownclk && ((theItem->pickup & ipTIMER && theItem->clk2 >= 32)
21803
5/10
✓ Branch 0 taken 559 times.
✓ Branch 1 taken 336 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 376 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 376 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
935 || (((itemsbuf[pitem].flags & ITEM_FLAG4)||(theItem->pickup & ipCANGRAB)||((itemsbuf[pitem].flags & ITEM_FLAG7)&&isKey)) && !priced && !(theItem->pickup & ipDUMMY))))
21804 {
21805 559 int32_t pickup = theItem->pickup;
21806 559 int32_t id2 = theItem->id;
21807 559 int32_t pstr = theItem->pstring;
21808 559 int32_t pstr_flags = theItem->pickup_string_flags;
21809
21810 559 std::vector<int32_t> &ev = FFCore.eventData;
21811 559 ev.clear();
21812 559 ev.push_back(id2*10000);
21813 559 ev.push_back(pickup*10000);
21814 559 ev.push_back(pstr*10000);
21815 559 ev.push_back(pstr_flags*10000);
21816 559 ev.push_back(0);
21817 559 ev.push_back(theItem->getUID());
21818 559 ev.push_back(GENEVT_ICTYPE_RANGED_DRAG*10000);
21819 559 ev.push_back(w->getUID());
21820
21821 559 throwGenScriptEvent(GENSCR_EVENT_COLLECT_ITEM);
21822 559 bool nullify = ev[4] != 0;
21823
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(nullify) continue;
21824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 559 times.
559 if(w->id == wBrang)
21825 {
21826 559 w->onhit(false);
21827 559 }
21828
21829
2/2
✓ Branch 0 taken 522 times.
✓ Branch 1 taken 37 times.
559 if(w->dragging==-1)
21830 {
21831 37 w->dead=1;
21832 37 theItem->clk2=256;
21833 37 w->dragging=j;
21834 37 theItem->is_dragged = true;
21835 37 }
21836 559 }
21837 935 }
21838 3337 }
21839 15969 }
21840 339161 }
21841 2072909 }
21842 2980512 }
21843 7262051 }
21844
21845 7262199 void dragging_item()
21846 {
21847
2/2
✓ Branch 0 taken 3041933 times.
✓ Branch 1 taken 7262199 times.
10304132 for(int32_t i=0; i<Lwpns.Count(); i++)
21848 {
21849 3041933 weapon *w = (weapon*)Lwpns.spr(i);
21850
21851
4/4
✓ Branch 0 taken 2722775 times.
✓ Branch 1 taken 319158 times.
✓ Branch 2 taken 3025626 times.
✓ Branch 3 taken 16307 times.
3041933 if((w->id == wBrang || w->id==wHookshot)&&itemsbuf[w->parentitem].flags & ITEM_FLAG5)//ITEM_FLAG5 is a port for qr_Z3BRANG_HSHOT
21852 {
21853
3/4
✓ Branch 0 taken 551 times.
✓ Branch 1 taken 15756 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 551 times.
16307 if(w->dragging>=0 && w->dragging<items.Count())
21854 {
21855 551 item* dragItem = (item*)items.spr(w->dragging);
21856 551 dragItem->x=w->x;
21857 551 dragItem->y=w->y;
21858
21859 // Drag the Fairy enemy as well as the Fairy item
21860 551 int32_t id = dragItem->id;
21861
21862
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 551 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
551 if(itemsbuf[id].family ==itype_fairy && itemsbuf[id].misc3)
21863 {
21864 movefairynew2(w->x,w->y,*dragItem);
21865 }
21866 551 }
21867 16307 }
21868 3041933 }
21869 7262199 }
21870
21871 28 int32_t more_carried_items()
21872 {
21873 28 int32_t hasmorecarries = 0;
21874
21875
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 28 times.
59 for(int32_t i=0; i<items.Count(); i++)
21876 {
21877
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 28 times.
31 if(((item*)items.spr(i))->pickup & ipENEMY)
21878 {
21879 28 hasmorecarries++;
21880 28 }
21881 31 }
21882
21883 28 return hasmorecarries;
21884 }
21885
21886 // messy code to do the enemy-carrying-the-item thing
21887 7262199 void roaming_item()
21888 {
21889
4/4
✓ Branch 0 taken 13238 times.
✓ Branch 1 taken 7248961 times.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 13198 times.
7262199 if(!(hasitem&(4|2)) || !loaded_enemies)
21890 7249001 return;
21891
21892 // All enemies already dead upon entering a room?
21893
1/2
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
13198 if(guys.Count()==0)
21894 {
21895 return;
21896 }
21897
21898 // Lost track of the carrier?
21899
5/6
✓ Branch 0 taken 13198 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13196 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 13187 times.
✓ Branch 5 taken 9 times.
13198 if(guycarryingitem<0 || guycarryingitem>=guys.Count() ||
21900 13196 !((enemy*)guys.spr(guycarryingitem))->itemguy)
21901 {
21902 11 guycarryingitem=-1;
21903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 for(int32_t j=0; j<guys.Count(); j++)
21904 {
21905
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 11 times.
35 if(((enemy*)guys.spr(j))->itemguy)
21906 {
21907 11 guycarryingitem=j;
21908 11 break;
21909 }
21910 24 }
21911 11 }
21912
21913
2/2
✓ Branch 0 taken 13164 times.
✓ Branch 1 taken 34 times.
13198 if(hasitem&4)
21914 {
21915 34 guycarryingitem = -1;
21916
21917
2/2
✓ Branch 0 taken 229 times.
✓ Branch 1 taken 34 times.
263 for(int32_t i=0; i<guys.Count(); i++)
21918 {
21919
2/2
✓ Branch 0 taken 195 times.
✓ Branch 1 taken 34 times.
229 if(((enemy*)guys.spr(i))->itemguy)
21920 {
21921 34 guycarryingitem = i;
21922 34 }
21923 229 }
21924
21925
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(guycarryingitem == -1) //This happens when "default enemies" such as
21926 {
21927 return; //eSHOOTFBALL are alive but enemies from the list
21928 } //are not. Defer to HeroClass::checkspecial().
21929
21930 34 int32_t Item=tmpscr->item;
21931
21932 34 hasitem &= ~4;
21933
21934
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if((!getmapflag(mITEM) || (tmpscr->flags9&fITEMRETURN)) && (tmpscr->hasitem != 0))
21935 {
21936 60 additem(0,0,Item,ipENEMY+ipONETIME+ipBIGRANGE
21937
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8 times.
34 + (((tmpscr->flags3&fHOLDITEM) || (itemsbuf[Item].family==itype_triforcepiece)) ? ipHOLDUP : 0)
21938 );
21939 34 hasitem |= 2;
21940 34 }
21941 else
21942 {
21943 return;
21944 }
21945 34 }
21946
21947
2/2
✓ Branch 0 taken 13953 times.
✓ Branch 1 taken 13198 times.
27151 for(int32_t i=0; i<items.Count(); i++)
21948 {
21949
2/2
✓ Branch 0 taken 755 times.
✓ Branch 1 taken 13198 times.
13953 if(((item*)items.spr(i))->pickup&ipENEMY)
21950 {
21951
2/2
✓ Branch 0 taken 8390 times.
✓ Branch 1 taken 4808 times.
13198 if(get_qr(qr_HIDECARRIEDITEMS))
21952 {
21953 8390 items.spr(i)->x = -128; // Awfully inelegant, innit?
21954 8390 items.spr(i)->y = -128;
21955 8390 }
21956
2/4
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4808 times.
4808 else if(guycarryingitem>=0 && guycarryingitem<guys.Count())
21957 {
21958
1/2
✓ Branch 0 taken 4808 times.
✗ Branch 1 not taken.
4808 if (!get_qr(qr_BROKEN_ITEM_CARRYING))
21959 {
21960 if (get_qr(qr_ENEMY_DROPS_USE_HITOFFSETS))
21961 {
21962 items.spr(i)->x = guys.spr(guycarryingitem)->x+guys.spr(guycarryingitem)->hxofs+(guys.spr(guycarryingitem)->hit_width/2)-8;
21963 items.spr(i)->y = guys.spr(guycarryingitem)->y+guys.spr(guycarryingitem)->hyofs+(guys.spr(guycarryingitem)->hit_height/2)-10;
21964 }
21965 else
21966 {
21967 if(guys.spr(guycarryingitem)->extend >= 3)
21968 {
21969 items.spr(i)->x = guys.spr(guycarryingitem)->x+(guys.spr(guycarryingitem)->txsz-1)*8;
21970 items.spr(i)->y = guys.spr(guycarryingitem)->y-2+(guys.spr(guycarryingitem)->tysz-1)*8;
21971 }
21972 else
21973 {
21974 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21975 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21976 }
21977 }
21978 items.spr(i)->z = guys.spr(guycarryingitem)->z;
21979 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21980 }
21981 else
21982 {
21983 4808 items.spr(i)->x = guys.spr(guycarryingitem)->x;
21984 4808 items.spr(i)->y = guys.spr(guycarryingitem)->y - 2;
21985 4808 items.spr(i)->fakez = guys.spr(guycarryingitem)->fakez;
21986 }
21987 4808 }
21988 13198 }
21989 13953 }
21990 7262199 }
21991
21992 bool enemy::IsBigAnim()
21993 {
21994 return (anim == a2FRMB || anim == a4FRM8EYEB || anim == a4FRM4EYEB
21995 || anim == a4FRM8DIRFB || anim == a4FRM4DIRB || anim == a4FRM4DIRFB
21996 || anim == a4FRM8DIRB);
21997 }
21998
21999 const char *old_guy_string[OLDMAXGUYS] =
22000 {
22001 "(None)","Abei","Ama","Merchant","Moblin","Fire","Fairy","Goriya","Zelda","Abei 2","Empty","","","","","","","","","",
22002 // 020
22003 "Octorok (L1, Slow)","Octorok (L2, Slow)","Octorok (L1, Fast)","Octorok (L2, Fast)","Tektite (L1)",
22004 // 025
22005 "Tektite (L2)","Leever (L1)","Leever (L2)","Moblin (L1)","Moblin (L2)",
22006 // 030
22007 "Lynel (L1)","Lynel (L2)","Peahat (L1)","Zora","Rock",
22008 // 035
22009 "Ghini (L1, Normal)","Ghini (L1, Phantom)","Armos","Keese (CSet 7)","Keese (CSet 8)",
22010 // 040
22011 "Keese (CSet 9)","Stalfos (L1)","Gel (L1, Normal)","Zol (L1, Normal)","Rope (L1)",
22012 // 045
22013 "Goriya (L1)","Goriya (L2)","Trap (4-Way)","Wall Master","Darknut (L1)",
22014 // 050
22015 "Darknut (L2)","Bubble (Sword, Temporary Disabling)","Vire (Normal)","Like Like","Gibdo",
22016 // 055
22017 "Pols Voice (Arrow)","Wizzrobe (Teleporting)","Wizzrobe (Floating)","Aquamentus (Facing Left)","Moldorm",
22018 // 060
22019 "Dodongo","Manhandla (L1)","Gleeok (1 Head)","Gleeok (2 Heads)","Gleeok (3 Heads)",
22020 // 065
22021 "Gleeok (4 Heads)","Digdogger (1 Kid)","Digdogger (3 Kids)","Digdogger Kid (1)","Digdogger Kid (2)",
22022 // 070
22023 "Digdogger Kid (3)","Digdogger Kid (4)","Gohma (L1)","Gohma (L2)","Lanmola (L1)",
22024 // 075
22025 "Lanmola (L2)","Patra (L1, Big Circle)","Patra (L1, Oval)","Ganon","Stalfos (L2)",
22026 // 080
22027 "Rope (L2)","Bubble (Sword, Permanent Disabling)","Bubble (Sword, Re-enabling)","Shooter (Fireball)","Item Fairy ",
22028 // 085
22029 "Fire","Octorok (Magic)", "Darknut (Death Knight)", "Gel (L1, Tribble)", "Zol (L1, Tribble)",
22030 // 090
22031 "Keese (Tribble)", "Vire (Tribble)", "Darknut (Splitting)", "Aquamentus (Facing Right)", "Manhandla (L2)",
22032 // 095
22033 "Trap (Horizontal, Line of Sight)", "Trap (Vertical, Line of Sight)", "Trap (Horizontal, Constant)", "Trap (Vertical, Constant)", "Wizzrobe (Fire)",
22034 // 100
22035 "Wizzrobe (Wind)", "Ceiling Master ", "Floor Master ", "Patra (BS Zelda)", "Patra (L2)",
22036 // 105
22037 "Patra (L3)", "Bat", "Wizzrobe (Bat)", "Wizzrobe (Bat 2) ", "Gleeok (Fire, 1 Head)",
22038 // 110
22039 "Gleeok (Fire, 2 Heads)", "Gleeok (Fire, 3 Heads)","Gleeok (Fire, 4 Heads)", "Wizzrobe (Mirror)", "Dodongo (BS Zelda)",
22040 // 115
22041 "Dodongo (Fire) ","Trigger", "Bubble (Item, Temporary Disabling)", "Bubble (Item, Permanent Disabling)", "Bubble (Item, Re-enabling)",
22042 // 120
22043 "Stalfos (L3)", "Gohma (L3)", "Gohma (L4)", "NPC 1 (Standing) ", "NPC 2 (Standing) ",
22044 // 125
22045 "NPC 3 (Standing) ", "NPC 4 (Standing) ", "NPC 5 (Standing) ", "NPC 6 (Standing) ", "NPC 1 (Walking) ",
22046 // 130
22047 "NPC 2 (Walking) ", "NPC 3 (Walking) ", "NPC 4 (Walking) ", "NPC 5 (Walking) ", "NPC 6 (Walking) ",
22048 // 135
22049 "Boulder", "Goriya (L3)", "Leever (L3)", "Octorok (L3, Slow)", "Octorok (L3, Fast)",
22050 // 140
22051 "Octorok (L4, Slow)", "Octorok (L4, Fast)", "Trap (8-Way) ", "Trap (Diagonal) ", "Trap (/, Constant) ",
22052 // 145
22053 "Trap (/, Line of Sight) ", "Trap (\\, Constant) ", "Trap (\\, Line of Sight) ", "Trap (CW, Constant) ", "Trap (CW, Line of Sight) ",
22054 // 150
22055 "Trap (CCW, Constant) ", "Trap (CCW, Line of Sight) ", "Wizzrobe (Summoner)", "Wizzrobe (Ice) ", "Shooter (Magic)",
22056 // 155
22057 "Shooter (Rock)", "Shooter (Spear)", "Shooter (Sword)", "Shooter (Fire)", "Shooter (Fire 2)",
22058 // 160
22059 "Bombchu", "Gel (L2, Normal)", "Zol (L2, Normal)", "Gel (L2, Tribble)", "Zol (L2, Tribble)",
22060 // 165
22061 "Tektite (L3) ", "Spinning Tile (Combo)", "Spinning Tile (Enemy Sprite)", "Lynel (L3) ", "Peahat (L2) ",
22062 // 170
22063 "Pols Voice (Magic) ", "Pols Voice (Whistle) ", "Darknut (Mirror) ", "Ghini (L2, Fire) ", "Ghini (L2, Magic) ",
22064 // 175
22065 "Grappler Bug (HP) ", "Grappler Bug (MP) "
22066 };
22067